Generator function* notation & short function syntax
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.
Thanks for the use cases and clarification
How, if at all, will generator function* (asterisk notation) be symmetrically applicable to arrow function or block lamba syntax?
References
Generators: harmony:generators Arrow Functions: strawman:arrow_function_syntax Block Lambda: strawman:block_lambda_revival