Generator function* notation & short function syntax

Brendan Eich brendan at
Wed Sep 7 14:43:25 PDT 2011

On Sep 7, 2011, at 1:26 PM, Rick Waldron wrote:

> How, if at all, will generator function* (asterisk notation) be symmetrically applicable to arrow function or block lamba syntax? 

Arrows could be used to express or define (see the let and const binding shorthands) generator functions:

let *gen() -> yield 42;

foo(*(a, b) -> { yield a; yield b; }); // pass a generator as a downward funarg

Note how * is lexed depending on parser state, akin to / in ES3+ -- if in operator position  * and / are the multiply and divide operators, if in operand position they're special forms: * must be followed by (...) or -> or => as part of a generator arrow; / of course would be the initial delimiter of a regexp.

Block-lambdas are not "just syntax" for functions, so there is no goal or requirement that they be able to express generators, any more that they be able to express constructors (|this| is lexical always in a block-lambda). This is yet more win for block-lambdas over arrows in my view.


> References
> Generators:
> Arrow Functions:
> Block Lambda:
> _______________________________________________
> es-discuss mailing list
> es-discuss at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list