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

%%

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

AssExpList:
        AssExp
|       AssExpList ',' AssExp
;

Exp:
        AssExp
|       Exp ',' AssExp
;

AssExp:
        ID
|       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.

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to