destructuring: as patterns?

Andreas Rossberg rossberg at google.com
Wed Apr 18 09:13:59 PDT 2012


On 18 April 2012 18:09, Herby Vojčík <herby at mailbox.sk> wrote:
> Andreas Rossberg wrote:
>>
>> On 18 April 2012 17:51, Herby Vojčík<herby at mailbox.sk>  wrote:
>>>
>>> Maybe allowing
>>>  let {b, b:{x,y}} = obj;
>>> would be enough. It sort-of comforms to existing syntax as well as
>>> semantics.
>>
>>
>> That won't work for arrays, for example.
>
> Yeah. :-/

Argument lists are the more interesting case, btw. Layering has to be
an independent and compositional construct.

> Then either not have it or syntax must be added for it.
>
> I'd say use '=' as in assignment:
>
>  let {b:b={x,y}} = obj;
>  let [a,b={x,y},c] = arr;

Unfortunately, that's already taken for default values, 'as' probably
is as good as you can get.

/Andreas


More information about the es-discuss mailing list