An array destructing specification choice

Axel Rauschmayer axel at rauschma.de
Fri Nov 11 17:31:20 PST 2011


>>>  [a0, a1, 〰〰, ak, ...r, bn, bn-1, 〰〰, b0]
>> 
>> We currently haven't specified this syntactic form.  I'm not sure if it adds enough value to justify the added conceptual complexity.
> 
> I think it's a pretty big win, and I'd argue it's totally intuitive. The great thing about destructuring is that you can intuit the semantics without actually having to understand the details of the desugaring/semantics.
> 
> Also: we'll definitely want to allow it for splicing, so the grammar will have to allow it already, and symmetry/consistency argue for allowing it in destructuring too. Likewise for function formals and actuals.


Using it for splicing suggests a construction analog:

let r = [2,3,4]
let arr = [0,1,..r, 5, 6, 7]

The grammar seems to support this, but I’ve never seen it in an example.

I might also be useful in parameter lists:

function foo(first, ...middle, last) {
} 

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111112/95258f9c/attachment.html>


More information about the es-discuss mailing list