From: dblack@... Date: 2007-02-17T03:53:42+09:00 Subject: Re: Oppinions on RCR for dup on immutable classes Hi -- On Sat, 17 Feb 2007, Phrogz wrote: > From: SonOfLilit [mailto:sonoflilit@gmail.com] > Sent: Friday, February 16, 2007 10:48 AM >> Ruby is always about principle-of-least-surprise and this behavior >> really surprised me when I first read about it non-list (I've stayed >> away from object copies in MY code, because it all seems so hacky and >> arcane to me... Truns out it was a good idea) > > Actually, Ruby is about the principle-of-least-surprise-for-matz. > > I used to think POLS applied to everyone when I started with Ruby. > Many people, including Matz, pointed out that it's impossible to make > things unsurprising to everyone, because people will be surprised by > different things. > > Just because something is surprising to you doesn't mean that it > should be changed in Ruby. You are advised (as was I) not to use POLS > as justification for why something should be changed. > > ... > > Having said that, I personally would prefer for 3.dup to 'just work', > returning an object that is equivalent to the original. Just because > the new instance happens to be the same doesn't mean that it's bad - > as an immutable object, the only way to tell is via object_id, anyhow. It doesn't mean it's bad, but it does mean that it isn't a duplicate :-) At least, I wouldn't think that dup is the right name for a method that might actually return the receiver. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)