On 5/22/12 4:31 PM, "Brendan Eich" <[email protected]> wrote:

>Herhut, Stephan A wrote:
>> Either, rather conservatively, that an unzip primitive be added to
>>Array/ParallelArray
>
>+1
>
>>   or that destructuring be extended such that if it encounters a lhs
>>object pattern and a rhs evaluating to an array of objects that it be
>>destructured into objects of arrays corresponding to variables specified
>>in the lhs.
>
>-1 to implicit unzip. This is fragile (EIBTI) and in fact arrays are
>objects, so breaking the equivalence of {0:x,1:y} and [x,y] (note no
>need to get 'length' in the latter pattern) seems unwarranted.

I agree, semantically arrays are just objects of a certain form. However,
by using an array instead of an object, I, the programmer, express an
intent of what I want to happen. For instance, I would expect constant
time lookup (I know, not always true in JS). So having pattern matching
work differently on arrays than on general objects would not come as a big
surprise to me. 

Having said that and given the identity crisis arrays have in JavaScript,
I understand your EIBTI comment.

Regarding your comment on length: I don't get that. If I do

let [x,y] = e;

where is length getting involved (other than in the destructuring
algorithm)?

Stephan

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to