From: Gregory Seidman Date: 2006-03-29T01:18:59+09:00 Subject: Re: Why do some methods names which replace the content in place doesn't have the "!" sign? On Wed, Mar 29, 2006 at 12:56:25AM +0900, dblack@wobblini.net wrote: [...] } I'm talking about Ruby, not C. In Ruby, you can modify a receiver } without changing its instance variables -- in fact, you can modify a } receiver that doesn't *have* any instance variables. } } irb(main):001:0> s = "" } => "" } irb(main):002:0> s.replace("abc") } => "abc" } irb(main):003:0> s.instance_variables } => [] } } The term "instance variable" has a specific and unambiguous meaning in } Ruby. I repeat, it's a technicality. A string's internal state is held in variables tied to the particular instance. They are not visible to the Ruby runtime, however, so they are not listed in the array returned by the object's instance_variables method. Do you really believe that methods, which modify those variables, do not change the instance variables simply because the runtime is unaware of the variables? No, I don't think so. You are arguing a technicality. You may be arguing this technicality because you think it is relevant to plausible implementations of const objects, and you may be right. Clearly, any methods that are not entirely implemented in pure Ruby would have to be explicitly marked as const or not since their const-ness could not be dicovered automatically. This is not unreasonable, however; extensions are special cases to begin with. } David --Greg