From: "Florian Groß" Date: 2005-03-21T22:42:01+09:00 Subject: Re: New block syntax Daniel Amelang wrote: > I really like the new proposed syntax for proc/blocks: > > b = {|| puts "good idea"} > > But the empty pipes make it ungraceful, in my opinion. I understand > the need to differentiate between the {} syntax for blocks and the {} > syntax for hashes. Thus, I propose that instead of changing the block > syntax to resolve the ambiguity, we change the hash syntax. If we require Hashs to be of the { key => value } form instead of the { key, value } form then I think we could differentiate blocks and hashes without needing the empty argument list. Ruby would however have to potentially parse quite a bit of the construct before it knows what to do with it as the key part of Hashes can be very complex -- still, I think this approach would be possible as lambda { 1 => 2 } is syntactically invalid. (I think perl handles this in a similar fashion, BTW) I dislike changing the Hash syntax as that's quite a big change for a small feature -- I don't think it is worth it. Perhaps if Ruby would have been designed with specifier-less lambdas this would have been a better option.