arrow function syntax simplified
Brendan Eich
brendan at mozilla.com
Tue Mar 27 14:28:39 PDT 2012
We went over this in the thread Isaac started. You'd need a [no LineTerminator here] between ) and {, and then the syntax looks too much like a juxtaposed parenthesized expression and block.
The latter problem, a lack of syntactic distinctiveness, also felled there entry mooted {(x)x} block-lambda alternative syntax.
/be
On Mar 27, 2012, at 5:22 PM, Russell Leggett <russell.leggett at gmail.com> wrote:
> 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
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120327/f61b680b/attachment.html>
More information about the es-discuss
mailing list