destructuring: as patterns?

Herby Vojčík herby at mailbox.sk
Wed Apr 18 09:09:33 PDT 2012


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. :-/
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;


> I agree that 'as' patterns (and even more so, wildcard patterns) are
> basic building blocks that are currently missing. They are extremely
> useful in practice, for a very small price -- i.e., they are trivial
> to spec and implement, (unlike callable objects, because Brendan just
> mentioned those :) ).
>
> /Andreas

Herby


More information about the es-discuss mailing list