An array destructing specification choice

Brendan Eich brendan at mozilla.com
Sat Nov 5 14:31:48 PDT 2011


On Nov 5, 2011, at 11:01 AM, John J Barton wrote:

> I can see why my version is wrong

Your interpretion is not wrong.


> But the feature does not do this. Rather, since LHS is array, it
> coerces the RHS to an array:
>  let z = coerceToArray(_rhs)[0];
> and we don't know what that operation means.

Definitely agree on that interpretation being mysterious!


> This example illustrates (again) why implicit type conversions sucks

Yup.


> (except to strings ;-).

Even then (the + operator).


> Can't this just be a error?

It could but it need not be the tail that wags the dog. Your previous mail showed the obvious desugaring, which was what Lars Thomas Hansen pioneered at Opera, which fed into ES4 and SpiderMonkey JS1.7 and up, and which is still what the harmony:destructuring proposal specs.

The addition of ... into patterns requires an interpretation. Error, all index properties ignoring any 'length' in the RHS, all index properties up to the length value, other we haven't thought of. Whatever we do this doesn't break the huge benefits of destructuring.

/be


More information about the es-discuss mailing list