Nannying (was: Array comprehension syntax)

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Sep 25 15:27:06 PDT 2012


On Sep 25, 2012, at 1:27 PM, Brendan Eich wrote:

> 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


agreed, this isn't about formal parsing ambiguity.

> ...;
> 
> 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.

So, from that perspective, why didn't you make it:

ArrLit:
       '[' AssExpList ']'
|       '[' Exp FOR ID OF Exp IF Exp ']'

Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120925/8e8c0e3c/attachment.html>


More information about the es-discuss mailing list