16:51 | <bradleymeck> | is there a reason we delegate out to Array#Symbol.iterator by default for classes w/o a constructor? just that it was easier to write the spec? |
17:40 | <ljharb> | i wouldn't expect the default constructor to differ from "code that does the same thing" |
17:41 | <ljharb> | also i assume you can't do `super.apply(null, arguments)` or anything, so you have to use `...` on the super call |
17:43 | <bradleymeck> | you can do things like spread the constructor via a literal generator |
17:43 | <bradleymeck> | it would act same as syntax but be... more complex looking |
17:43 | <bradleymeck> | in reality engines wouldn't need to do those things |
17:48 | <ljharb> | a literal generator? |
17:49 | <bradleymeck> | super(...(function* () {let i = 0; while (i < args.length) yield args[i++];})()) |
17:50 | <bradleymeck> | though i guess that implicitly relies on the generator prototype being safe |
17:50 | <ljharb> | wouldn't that be vulnerable to deleting Iterator.prototype[Symbol.iterator]? |
17:50 | <ljharb> | i don't think array spread can ever be a safe/robust operation |
17:50 | <ljharb> | i suspect we'd need a way to use `arguments` and `.apply` with `super` |
17:50 | <bradleymeck> | i'd agree, this is a problem in node's SafeMap impl as well |
17:50 | <bradleymeck> | rest params are safe |
17:50 | <ljharb> | doesn't SafeMap have a nonconfigurable prototype property tho? |
17:50 | <bradleymeck> | no need to use arguments |
17:51 | <bradleymeck> | ljharb: yea, but the super call in unsafe YOLO |
17:51 | <ljharb> | right, but the resulting call to `super` isn't |
17:51 | <ljharb> | right |
17:51 | <ljharb> | lol you could for-loop over the args in the SafeMap constructor and build a SafeSet, and then spread that into `super` :-p |
17:51 | <ljharb> | or the same with a "SafeArguments" construct |
17:52 | <bradleymeck> | i mean safeset also leaks idk if that would fix it |
17:52 | <bradleymeck> | in general super(...varargs) is just dangerous imo |
17:53 | <bradleymeck> | until we have a way to properly spread w/o hooks |
17:53 | <ljharb> | right |
17:53 | <ljharb> | if we had that, i'd be 1000% in favor of changing the default constructor |
17:54 | <ljharb> | i wonder if it'd be web compatible to make spreading of an IsArray() *not* delegate to Symbol.iterator? i guess that'd mess with array subclasses tho. but maybe if the constructor is %Array%? |
17:55 | <bradleymeck> | moving this to TC39 idk why my brain put this here |