Block lambda is cool, its syntax isn't

Axel Rauschmayer axel at rauschma.de
Thu Jan 12 22:23:57 PST 2012


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


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... ;-)

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)

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.

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



More information about the es-discuss mailing list