From: Yukihiro Matsumoto Date: 2008-05-27T00:48:21+09:00 Subject: Re: [PATCH] lambda with normal block syntax Hi, In message "Re: [PATCH] lambda with normal block syntax" on Mon, 26 May 2008 23:14:56 +0900, Dave Thomas writes: |You asked people to try the patched syntax that allows | | meth {|a| a+1}, {|b| b*2} | |I think that this particular syntax is a lot less obtrusive, and a lot |easier to recognize, than | | meth -> a { a + 1}, -> b { b * 2 } | |The first one is obviously a couple of blocks: that's what I read when |I see {|a| ...}. | |It seems that most of the posters on this thread agree. And, using |your criteria of "try it for a while and see", I'd judge that people |have tried -> for a while, and might well be happier with the {|| } |version. Personally I don't like meth {|a| a+1}, {|b| b*2} which can be parsed (meth() {|a| a+1}), ({|b| b*2}) or meth({|a| a+1}, {|b| b*2}) or whatever. I dislike this kind of ambiguity. In fact, you would expect the latter, but I'm afraid Eric's patch gives you the former. This could be a very evidence of (bad) ambiguity. That's why I asked people to try the patch. Perhaps it works better with Groovy's semantics of block passing (last explicit argument with slightly different call syntax). But not with Ruby's implicit argument style, which I am not going to change. |I'd also argue that the {|a| } makes for a better language. My |experience teaching this stuff shows that people are confused by the |large number of different options that surround blocks. Unifying block |parameters with method parameters, and then removing the need for this |somewhat strange -> notation, will reduce the number of special cases, |and make it a lot easier for people to understand the language. And |that's a major cognition win. This notation introduces something new (a block without any attached method, or lambda), with syntax almost indistinguishable from existing one (a block attached to a method). I hesitate to give too similar syntax to something different. The point should be how different (in recognition) a block without attached method (lambda) and an usual block in Ruby. I see them different (at least in Ruby). Others may not. |Please, please consider adding both these patches into 1.9. * block parameter with default argument patch: likely. * block without attached method patch: need more persuasion. matz.