22:16 | <TabAtkins> | Sorry, I don't want to test this if someone already has the knowledge off-hand: if you array-destructure an actual array, does it invoke the iterator protocol or just yoink from the numbered properties directly. and does this apply to array-likes as well? |
22:25 | <Richard Gibson> | yes to both; array-destructuring is defined to depend upon the iterator protocol (which for most built-ins, particularly including Array.prototype , is mutable by ECMAScript code)DestructuringAssignmentEvaluation |
22:27 | <TabAtkins> | k, cool |
22:27 | <TabAtkins> | that means i don't need to worry about making this more efficient in another proposal ^_^ |
23:00 | <bakkot> | for this reason you will sometimes see people doing let {0: x, 1: y} = array , because it skips the iterator protocol |
23:13 | <Richard Gibson> | aw crud, it looks like every implementation diverges from the spec for
(all three should invoke |
23:34 | <bakkot> | I suspect that's due to implementing the spec as it was prior to https://github.com/tc39/ecma262/pull/1021, and then only doing the update necessary to make https://github.com/tc39/test262/pull/1248 pass |
23:40 | <bakkot> | wait, no |
23:40 | <bakkot> | Richard Gibson your test is just wrong |
23:40 | <bakkot> | generators don't do anything when invoked |
23:41 | <bakkot> | (except evaluate parameter defaults IIRC) |
23:41 | <bakkot> | they only do something when you first call next |
23:41 | <bakkot> |
gives
in all engines, just as it should |
23:44 | <Richard Gibson> | phew |
23:52 | <Richard Gibson> | well, not all engines: https://github.com/Moddable-OpenSource/moddable/issues/1223 |
23:58 | <bakkot> | ah yeah I don't have xs installed I guess |