too-early feedback implementing ECMA6 array comprehension syntax
allen at wirfs-brock.com
Fri Jun 8 16:15:17 PDT 2012
On Jun 8, 2012, at 3:58 PM, Brendan Eich wrote:
> Allen Wirfs-Brock wrote:
>> It may well be that the initial Expression of the ArrayComprehension productions should be an AssignmentExpression in order to avoid commas.
> This is just a draft-spec grammar bug. What I implemented in SpiderMonkey many years ago is what is grammatically necessary: AssignmentExpression. Otherwise you have not only a readability problem as Jay wrote, but a real problem in top-down parsers deciding whether you are in an array initialiser or array comprehension. Bottom up parsers can cope but practical implementations are all top-down.
What do you think about the expression following the of or if of a comprehension, assuming we are going to be paren-free. Both can be in a trailing position within a comprehension. I don't think there are any parsing issue with them, but they represent similar readability issues:
[ i for i of foo, bar]
[i for i of foo if i!=="bar", false]
Assignment expression would eliminate that reability issue. Of course, so would mandatory parrens.
More information about the es-discuss