On Mon, Sep 09, 2002 at 09:05:49PM +0900, Takaaki Tateishi wrote:
> [ruby-dev:18114] Object#become
> 
>   Koji Arai asked what is a difference between "replace" and "become"
>   of String, Array and Hash. Matz answered that there is semantically
>   no difference between them at present. But it is not decided how
>   they come to be.

Interesting question.

Someone on irc pointed out that there is an Object#become in CVS now.
When I look at the source, though, it doesn't look like it does anything
except raise an exception if obj is frozen or if obj and orig are not
the same type.  Then it returns the original object.

I also notice that Object#become gets called by copy_object, right after
setting the flags in the destination object and right before copying the
instance variables.

Questions:

  1) Is this how Object#become is supposed to behave, or is this a
     work-in-progress?

  2) What logic is there in using Object#become to implement copying of
     the object?  I was under the impression that Object#become was
     supposed to "swap" the objects, which would make it hard to use for
     copying.

  3) Why doesn't Object#become copy the instance variables, instead of
     having copy_object copy them?

Paul