Different semantics should have different-looking syntax

Brendan Eich brendan at mozilla.com
Sat May 21 23:54:26 PDT 2011

On May 21, 2011, at 9:57 PM, Bob Nystrom wrote:

> 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!

Good one-liner A/B comparison -- thanks.


P.S. This will help kill something in ECMA-357, E4X, that is sugar for 'with', where the sugar hooks the kids on the poison. The lightweight syntax of blocks is just about needed, including paren-free calls (not used in your example, good choice -- and good to have the choice).

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

More information about the es-discuss mailing list