Arrow function syntax cover syntax

Erik Arvidsson erik.arvidsson at
Sat Apr 7 13:40:51 PDT 2012

"This works because Expression is a cover grammar for
FormalParameterList, with Identifier primary expressions covering
formal parameter names, array and object literals for destructuring,
assignment for parameter default values, and spread for rest

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:


desugars to

var $tmp = expression;
($tmp[0], $tmp[1], ..., $tmp[$tmp.length - 1])

but that is kind of useless.


More information about the es-discuss mailing list