Block lambda is cool, its syntax isn't

Brendan Eich brendan at mozilla.org
Thu Jan 12 22:58:38 PST 2012


> Axel Rauschmayer <mailto:axel at rauschma.de>
> January 12, 2012 10:23 PM
>
>
> Two more pro-pipe points: block lambdas (lambda blocks?) will often be 
> arguments of functions:
> foo( {|x,y| x + y } )
> foo( {(x,y) x + y } )
>
> With parens, you are starting to look a bit like Lisp... ;-)

Agreed, although note that you can go paren-free in the call:

   foo {|x,y| x+y}

But there will be paren-ful call cases.
>
> I also find that pipes stick out better as something alien. Parens 
> feel too much like someone has forgotten to add a semicolon, inside a 
> normal block:
> https://gist.github.com/d2c8fcbab5a3da4c4dae (Rick Waldron’s Gist 
> comparing parens and pipes)

Yup.
>
> But man does that code profit from block lambdas – really nice to look 
> at. In some cases, things would fit into a single line where you were 
> forced to split into multiple lines without BLs.

It's not just the line savings -- the lack of 'function'deadwood and 
'return' just to have a result value win too. (I didn't see any 
TCP-based control effects.)

/be
>
> Brendan Eich <mailto:brendan at mozilla.org>
> January 12, 2012 7:33 PM
> The correspondence principle is a big change for the body, so even if 
> we could reserve block or abuse do, making the special form look like 
> function (params) { body } is a mistake. 'return' does not return from 
> the block, it returns from the enclosing function.
>
> I'm not in love with Ruby syntax but {(a, b) a + b} isn't as 
> distinctive and clearly a lambda-like thing. You're right about that, 
> but turning back to function-based syntax with a different 
> introductory keyword goes the wrong direction. This is why I keep 
> coming back to "different syntax is a virtue". The 
> correspondence-principle-based semantics are different enough.
>
> /be
>
> Tab Atkins Jr. <mailto:jackalmage at gmail.com>
> January 12, 2012 5:44 PM
>
> I agree. While Ruby and Smalltalk are useful to continue mining for
> ideas, they shouldn't be a source of syntax, as they're not
> super-popular. Using || to denote an argument list looks *bizarre* to
> my eyes, and I suspect also to the eyes of every single person who's
> used a C-like language but not Ruby.
>
> I'm not wedded to {(a,b) a + b} for blocks either, but it's at least
> an improvement over {|a,b| a + b}. I wouldn't mind something simple
> like "block(a,b){a+b}" or even "do(a,b){a+b}", though those probably
> run into ambiguity issues.
>
> ~TJ
> _______________________________________________
> 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/20120112/d7ab5053/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1222 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/d7ab5053/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1290 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/d7ab5053/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1021 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/d7ab5053/attachment-0002.jpg>


More information about the es-discuss mailing list