Nannying (was: Array comprehension syntax)

Brendan Eich brendan at
Tue Sep 25 13:27:18 PDT 2012

Allen Wirfs-Brock wrote:
> I note that in your toy grammar you avoid the comma issue at the front and in the for clauses by using AssignmentExpression in those positions. 
> The current ES6 spec. draft has AssignmentExpression at the front, and Expression in the for and if clauses.  However, there is also a editor's note that suggests that AssignmentExpression should be considered for all three positions. 

There's still no ambiguity if the toy grammar changes to

%token FOR
%token ID
%token IF
%token OF


         '[' AssExpList ']'
|       '[' AssExp FOR ID OF Exp IF Exp ']'

|       AssExpList ',' AssExp

|       Exp ',' AssExp

|       ID '=' AssExp

The "readability" concern would matter if people actually wrote 
unparenthesized comma expressions in such comprehensions, but Nanny-me 
says they won't, and Mary Poppins agrees.

Again, it's not our job to prevent people from writing something that 
might confuse someone. JS has lots of room in its grammar for that. I 
agree with Dave, in absence of evidence of real ambiguity or another 
technical grammar problem.


More information about the es-discuss mailing list