Maybe ban holes, then... (was: Re: lexical for-in/for-of loose end)
Allen Wirfs-Brock wrote: That said, I'd hate to see things like: [,x] = someArray; and even [a,,y] = someArray; can be easily missed. It isn't clear to me that we are doing ES programmers (especially those with poor eyesight) a favor by allowing such expressions. What is the evidence with JS1.7 up. How much usage do we see of such holes? If {5:x} = someArray; and {0:a, 2:y} = someArray; would be possible, there is probably little need for holes. In case of [a,b,c,d,,f] = someArray; one could always use (some conventional) anon-var, like _ (from Prolog): [a,b,c,d,_,f] = someArray; Herby ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Maybe ban holes, then... (was: Re: lexical for-in/for-of loose end)
This is all unwanted innovation. We have holes in arrays, and in SpiderMonkey and Rhino we've had holes in destructuring array patterns for years. No one got confused or went blind. We should stop nanny-ing about holes. Some of you don't like holes, but they're not going away in arrays. They are useful in array patterns to avoid _ or junk bindings. That's enough to keep them, rather than straining to invent more cumbersome ad-hoc replacements. /be Herby Vojčík mailto:he...@mailbox.sk February 2, 2012 11:49 AM If {5:x} = someArray; and {0:a, 2:y} = someArray; would be possible, there is probably little need for holes. In case of [a,b,c,d,,f] = someArray; one could always use (some conventional) anon-var, like _ (from Prolog): [a,b,c,d,_,f] = someArray; Herby ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Maybe ban holes, then... (was: Re: lexical for-in/for-of loose end)
Allen Wirfs-Brock wrote: It isn't just possible, it is already specified as valid. and youdon't need the quotes around the array indices. But you need a set ofparams to deal with the expression statement can't start with { problem. This wouldn't be the case for binding position destructuring. ({5:x} = someArray); ({0:a, 2:y} = someArray); A bit off-topic... I don't like paretheses. Not only because I have to put them in both ends, but also because of uncomfortable feeling of thing closed in parentheses. Maybe alternative convention to deal with expressions beginning with { could be used as well: 0, {5:x} = someArray; 0, {0:a, 2:y} = someArray; Herby ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Maybe ban holes, then... (was: Re: lexical for-in/for-of loose end)
On 2 February 2012 21:19, Brendan Eich bren...@mozilla.org wrote: Some of you don't like holes, but they're not going away in arrays. They are useful in array patterns to avoid _ or junk bindings. That's enough to keep them, rather than straining to invent more cumbersome ad-hoc replacements. Are you implying that wildcards are more ad-hoc than array holes? That doesn't add up for me. /Andreas ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss