On Nov 5, 2011, at 2:34 PM, Brendan Eich wrote:
> On Nov 5, 2011, at 11:27 AM, Allen Wirfs-Brock wrote:
>
>>> It should, as no length is assumed to mean "length === 0", IIUC, and
>>> that seems so unintuitive to me that it sways my opinion towards not
>>> imposing array-ness on the RHS.
>>
>> but that is exactly how it works everywhere else length is used in ES.
>
> Who says 'length' is used by an array destructuring pattern. That should not
> be assumed.
just to clarify, everywhere else a range of "array" elements is used, the range
is limited by the value of the "length" property. Regardless of where or not
the object in question is a "real" array.
>
>
>> So you would be fine with the fact that
>>
>> var r = Array.prototype.slice.call(0:0, 1:1, length: 2, 2:2}, 0);
>>
>> produces [0,1]
>>
>> but
>>
>> var [...rx] = {0:0, 1:1, length: 2, 2:2};
>>
>> produces [0,1,2]
>
> Even if Till would not (and it's clear you would not be fine with this
> outcome ;-), we have a choice. We can make array destructuring patterns that
> do not use ... ignore any RHS 'length' property. We could even forbid this
> kind of "row capture" -- I'm not in favor.
I was fine with it to, until ... came along. If ... uses length (and I think
it probably should, as I touched on in another reply) then element access also
should)
>
> Row capture in object patterns requires enumeration of RHS properties. Have
> you worked on that case too?
No, row capture was never accepted as part of the proposal.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss