[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Cloning into an object

Eric Mahurin

5/1/2005 1:47:00 PM

> > I read a little more about become. It looks like it might
> be
> > made standard in ruby at some point. Will it have the
> above
> > functionality. Or will it do something like what I think
> the
> > smalltalk "become" does - change all references to the
> > destination object to point to the source object. I really
> > don't want the reference changes because a) it seems very
> > expensive (search the object space), and b) this would
> cause
> > the object id to change.
>
> I thought that was the whole point of "become". Certainly it
> doesn't
> make sense for references to object x to persist in being
> reference to
> object x if object x has "become" object y. (The idea of
> having this
> in Ruby doesn't appeal to me, but that's my understanding of
> its
> premise, anyway.)


What evil.rb has works great for me. It should probably be
called "replace" like the methods in Array, Hash, and String.
evil.rb/become is just a more general form of the replace in
Array, Hash, and String.




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail...


1 Answer

Florian Groß

5/2/2005 6:33:00 AM

0

Eric Mahurin wrote:

> What evil.rb has works great for me. It should probably be
> called "replace" like the methods in Array, Hash, and String.
> evil.rb/become is just a more general form of the replace in
> Array, Hash, and String.

I agree that "replace" would be nice, but on the other hand I think the
fact that it is not guaranteed to work for all combinations of target
and source objects would be incompatible with that name. Plus there is
border cases where .replace works differently, I think, because it calls
to_ary.

"become" has been chosen because that is what this feature is usually
called in Smalltalk.