Arrow function syntax cover syntax

David Herman dherman at mozilla.com
Mon Apr 9 14:05:22 PDT 2012


On Apr 7, 2012, at 1:40 PM, Erik Arvidsson wrote:

> This does not work for rest parameter since ... is only allowed inside
> array literals.
> 
> var tail = (x, ...xs) => xs;
> 
> This can of course be solved in numerous ways but it is not true that
> the Expression is a cover grammar for FormalParameterList.
> 
> Another option is to allow ...expression in an expression which would
> have the same semantics as a comma expression where the expression has
> been spread:

Or allow it in the grammar and then disallow it in the post-processing. IOW, a cover grammar doesn't have to force us to introduce new syntactic forms, they just force us to put them in the *grammar*. The post-processing, which essentially defines the two sub-grammars for the two separate contexts, can remove the syntactic forms we don't want to provide semantics for.

Dave



More information about the es-discuss mailing list