Array comprehension syntax

Brendan Eich brendan at mozilla.org
Sat Sep 22 09:24:29 PDT 2012


Jason Orendorff wrote:
> I'm sorry for the confusion here.  I didn't mean to propose adding
> for-each-in to ES6.  That would indeed be awful.  I just meant that
> SpiderMonkey cannot necessarily drop this extension.  So if the ES6
> syntax and SpiderMonkey's syntax can't coexist, it will be a problem
> for us.

Not to bother es-discuss too much, but in case there's interest:

I do hope we can retire 'each' from SpiderMonkey at some point. 
Supporting it in comprehensions has a cost. Your example:

  [x for each(x in obj).y of z]


can't be parsed without error given our current for-each implementation, 
and backtracking and restarting with 'each' not contextually meaningful 
sounds "fun".

I don't expect a lot of SpiderMonkey- (and Rhino-) specific code will 
break, so making this an error when we support ES6 may be the best way. 
Pull the bandage off quickly!

/be


More information about the es-discuss mailing list