From: ES Date: 2005-06-02T10:46:11+09:00 Subject: Re: Method Chaining Issues Le 2/6/2005, "Nikolai Weibull" a �crit: >ES wrote: > >> > > class Foo >> > > def initialize >> > > @a = 5 >> > > end >> > > >> > > attr_accessor :a >> > > end >> > > >> > > foo = Foo.new >> > > foo.a = 6 >> > > >> > > Current behaviour aside, should the last line create a new Foo object? >> > >> > Very funny. Totally different argument, >> >> This is the counterargument for keeping destructive methods. > >No it���s not. This is an argument for keeping Ruby non-functional. This >has nothing to do with String#sub vs. String#sub! or Array#sort vs. >Array#sort! for that matter. When discussing destructive methods with >bangs, we���re discussing the merit of having String#sub! around for >efficiency reasons. It���s not a discussion of whether to allow objects >to modify their internal state or not. I know you know this and I know >what you���re trying to say, but this doesn���t lead anywhere, It is relevant to the discussion on whether the bang-methods should be deprecated (that was the topic). Efficiency usually does not factor in apart from high-volume transactions, so the only remaining valid argument for them is a conceptual one. If I want to modify a String, I want to modify it, not create a new one and assign it to the space of the old one. The conceptual benefit of this is, of course, more prominent in contexts other than Strings as shown by the Foo example. > nikolai E -- template void quack(duck& d) { d.quack(); }