Generator function* notation & short function syntax
Rick Waldron
waldron.rick at gmail.com
Wed Sep 7 14:50:31 PDT 2011
Thanks for the use cases and clarification
Rick
On Wed, Sep 7, 2011 at 5:43 PM, Brendan Eich <brendan at mozilla.com> wrote:
> 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
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110907/1d028a67/attachment.html>
More information about the es-discuss
mailing list