Fwd: Array comprehension syntax
Jason Orendorff
jason.orendorff at gmail.com
Sat Sep 22 10:10:28 PDT 2012
On Sat, Sep 22, 2012 at 11:21 AM, Brendan Eich <brendan at mozilla.org> wrote:
> Perhaps the thing to do is keep to Python: for+ if? if you get my
> pidgin-EBNF.
But that isn't Python's syntax.
Python's comprehensions are: for (for|if)*
Haskell's comprehensions are: (for|if|let)*
This is what I would prefer for JS.
Clojure's comprehensions are: for+ (if|while|let)*
Clojure puts the expression at the right, which I like, for the
reasons Allen mentioned.
CoffeeScript's comprehensions are: for when?
Only a single 'for' clause. It can't be used to flatten an array of arrays.
I actually kind of like Allen's argument about not wanting to
encourage the use of array comprehensions for complicated use cases.
However I'm not sure how that squares with a distaste for nanny syntax
restrictions! :)
-j
More information about the es-discuss
mailing list