Different semantics should have different-looking syntax

Bob Nystrom rnystrom at google.com
Sat May 21 21:57:22 PDT 2011


On Sat, May 21, 2011 at 1:24 PM, Brendan Eich <brendan at mozilla.com> wrote:

> > It turns out now that it's really a dilemma what to choose -- arrows or
> blocks... have to think.
>
> Arrow function syntax is "just syntax". I will drop it if we can agree on
> block lambda revival. As @_sjs (Sami Samhuri) tweeted at me, "We'll always
> have function." ;-)
>

I was worried that using these lambda blocks would be heavier-weight for the
functional idiomatic use cases where -> really shines. But since this
proposal also allows an implicit return, this actually ends up being even
more terse than -> functions:

let names = people.filter((p) -> p.lastName == 'Smith').map((p) ->
p.firstName);
let names = people.filter({|p| p.lastName == 'Smith'}).map({|p|
p.firstName});

For me, this is pretty compelling. It covers both the "roll your block
structure" use case and the "lightweight lambda" one. Nice!

- bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110521/4b2ab340/attachment.html>


More information about the es-discuss mailing list