From: Eric Mahurin Date: 2005-08-11T04:09:39+09:00 Subject: Re: new block notation --- Ben Giddings wrote: > On Aug 6, 2005, at 11:36, Daniel Brockman wrote: > > I guess the confusion is this: > > > > {} # hash > > {||} # proc > > foo {} # block > > foo({}) # hash > > foo {||} # block > > foo({||}) # proc > > > > Compare that to the arguably saner > > > > {} # proc > > {||} # proc > > foo {} # block > > foo({}) # proc > > foo {||} # block > > foo({||}) # proc > > [:] # hash > > foo [:] # hash > > foo([:]) # hash > > I agree that the current syntax is really confusing. Since > Ruby 2.0 > has a new major version number, I think that fixing > confusing/broken > things should take precedence over backwards-compatibility. > It's all > up to Matz and what he finds least surprising, but to me the > current > syntax for arrays and blocks is too confusing. I would > prefer it > they were made unambiguous > > I'd vote for either getting rid of {} for blocks and only > allowing > 'do ... end'. That may be an unpopular suggestion, but I > think it > makes the most sense. It's already a little confusing that > there are > two equal, yet different ways of creating a block. > > This leads to people having their own conventions, like using > {} only > when it's a one-line block, and do ... end when it's a > multiline > block; or using {} when it returns a value, but do ... end > when it > doesn't. > > Whatever the resolution though, I would prefer to see a > situation > where only one of blocks and hashes used {}, despite the > backwards- > compatibility issues. I agree with this last statement too. I'd rather keep the {} for blocks/lambdas. But, I don't think we should move the ambiguity from blocks vs. hashes (overloading {}) to arrays vs. hashes (overloading []). It would be better for hashes to just have their own unambiguous syntax. ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs