destructuring: as patterns?

Herby Vojčík herby at mailbox.sk
Wed Apr 18 08:51:14 PDT 2012


David Nolen wrote:
> On Wed, Apr 18, 2012 at 11:26 AM, Brendan Eich <brendan at mozilla.org
> <mailto:brendan at mozilla.org>> wrote:
>
>     We've supported destructuring for years and no one has asked for
>     this. I say YAGNI and when in doubt, leave it out. One can always
>     write two destructuring declarations without much repetition:
>
>
> But who has been using it? Certainly not the general JS development
> community.
>
>       let {b} = obj;
>       let {x,y} = b;

Maybe allowing
   let {b, b:{x,y}} = obj;
would be enough. It sort-of comforms to existing syntax as well as 
semantics.

>
>     but of course one would just write
>
>       let {x, y} = obj.b;
>
>     in that contrived case.
>
>     Main thing is, not having as-patterns is not a big deal based on
>     experience with JS1.7+ since 2006 in Mozilla code.
>
>     /be
>
>
> I've found it quite useful in Clojure/Script and I'm sure folks who have
> encountered the feature in the ML derived languages would agree.
>
> David

Herby


More information about the es-discuss mailing list