arrow function syntax simplified

Russell Leggett russell.leggett at gmail.com
Tue Mar 27 15:40:57 PDT 2012


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

> 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.
>
>
Makes sense. I think the required block in one and the required lack of
block in the other should be enough for distinguishing the two. I can get
behind this. The => does combine nicely with do expression, and hits a
sweet spot on its own.

- Russ



> /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<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/2075397c/attachment.html>


More information about the es-discuss mailing list