Block lambda is cool, its syntax isn't

Tab Atkins Jr. jackalmage at gmail.com
Thu Jan 12 17:44:30 PST 2012


On Thu, Jan 12, 2012 at 4:26 PM, Thaddee Tyl <thaddee.tyl at gmail.com> wrote:
> I have heard many fellow programmers say that, while block lambdas
> would be welcome, Ruby's |a, b| syntax is ugly.
> I thought I was the only one feeling this way, but since I am not, I
> would like to ask why the parentheses cannot be used there.
>
>    { (a, b) a + b }
>
> cannot conflict with any existing program; at least I don't see how it can.

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


More information about the es-discuss mailing list