arrow function syntax simplified

Russell Leggett russell.leggett at gmail.com
Tue Mar 27 14:22:52 PDT 2012


On Tue, Mar 27, 2012 at 3:43 PM, Brendan Eich <brendan at mozilla.com> wrote:

> http://wiki.ecmascript.org/**doku.php?id=strawman:arrow_**function_syntax<http://wiki.ecmascript.org/doku.php?id=strawman:arrow_function_syntax>
>
> Use => only with an expression body (do-expressions if accepted allow
> statements and combined with => compete with block-lambdas).
>
> Use -> only with body block, as for long-form function.
>

Just a thought - if a block is required on the RHS of the ->, why not just
skip the arrow? I could be mistaken, but would it be just as easy
grammatically to do:

    array.forEach((v, i) { if (i & 1) oddArray[i >>> 1] = v; });

instead of:

     array.forEach((v, i) -> { if (i & 1) oddArray[i >>> 1] = v; });

This way, there would only be one kind of arrow.  Without an arrow its
basically just removing the keyword function, and therefore maybe a little
bit easier to transition. With the arrow added, you can expect a bigger
jump in semantics.

- Russ



>
> I deferred other accretions.
>
> In a rush here, comments and corrections welcome and I'll edit as I can.
>
> /be
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120327/6434826c/attachment.html>


More information about the es-discuss mailing list