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.
/be
>
> References
>
> Generators: http://wiki.ecmascript.org/doku.php?id=harmony:generators
> Arrow Functions:
> http://wiki.ecmascript.org/doku.php?id=strawman:arrow_function_syntax
> Block Lambda:
> http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss