Hi --

On Sun, 1 Nov 2009, Jordi Bunster wrote:

> On Oct 31, 2009, at 1:03 PM, David A. Black wrote:
>
>> I don't think "replace" has any generalizable semantics. You can't
>> replace 2 with 3, for example (fortunately :-)
>
> You could just memcpy a to b (as long as their classes are eql?). If for a 
> given object it doesn't make sense, like for singleton ones, then you don't 
> allow it.
>
> I wonder if they would take a patch. Is not as if Ruby doesn't already have a 
> ton of edge cases anyway.

The "There's a precedent" argument can always be inverted, though,
into the "We've reached our quota" argument :-) Of course, that's
where Matz and his wonderful sense of balance come in.

In any case, I wouldn't call such a method "replace", because it's
radically different from the existing replace methods. Somewhere
there's at least one implementation (maybe in evil.rb) of a method
called "become", which I think does what you're describing, or
something similar: a.become(b) means that all existing references to a
become references to b, if I'm remembering/summarizing correctly.


David

-- 
The          Ruby training with D. Black, G. Brown, J.McAnally
Compleat     Jan 22-23, 2010, Tampa, FL
Rubyist      http://www.thecompleatrubyist.com

David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)