On 5 October 2011 21:19, Sean Eagan <[email protected]> wrote:

> However, I don't see why variable declaration array destructuring
> binding and parameter lists should be different in any way.  The only
> current syntactic difference between them is elision:
>
> // allowed
> function f([,,,,,,x]){}
> // disallowed
> function f(,,,,,,x){}
>

Only apropos of semantics, but I really don't like this syntax at all. It is
far, far too easy to overlook a hole. I think we should forbid this syntax
in Harmony.

If we want to support "holes" in patterns -- and I'm all for it! -- then we
should do what all other languages with proper pattern matching do and
introduce explicit syntax for wildcards, namely "_". That simplifies both
syntax and semantics (because it's more compositional) and increases
readability:

function f([_, _, _, x]){}
> function f(_, _, _, x){}
>

This has been suggested before, but I want to reinforce the point.

(I'm far less convinced about allowing holes in expressions, but an argument
could be made that "_" is simply syntax for undefined in expressions. No
more writing "void 0".)

/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to