From: Florian Gross Date: 2005-01-20T08:01:01+09:00 Subject: Re: value by reference why the lucky stiff wrote: > Florian Gross (flgr@ccan.de) wrote: > >>>So far, the cons are two: >>> >>>1. The current model doesn't support it. >>>2. The performance would be poor: >>> >>>[...] but maybe that statement ("ruby doesn't >>>work that way") is enough to stop any further improvement. >> >>I disagree. I think there are some core principles of Ruby that make it >>Ruby. These should not change, especially not if there are no good >>sample situations that would require the change to work correctly. > > Disagreement here as well. I've needed Object#become quite a bit in my > travels and I think Ruby could support it without incurring cost. It's > as simple as a memcpy of an RStruct. Actually, it isn't. Have a look at the evil-ruby project. There is a lot of cases that can lead to segfaults and endless loops with such a naive implementation. It's especially important that the RStructs are compatible meaning you can not use it generally anyway. I don't quite see how the two things (introducing variable-by-ref semantics) and Object#become are related. Plus I was sort of arguing against the stuff I quoted, e.g. not wanting to implement a feature in the general case. > I only have one use case: I'm building a complex Ruby object, when I find > a point of recursion or transformation which requires me to retrace my > steps and replace a node farther back in the tree. If it's a tree then there will usually only be one place that refers to your Object. It ought to be possible to replace it even without #become. As said: Note that I'm not against toying around with ideas or implementing well tested ideas that match up with the languages core philosophy without introducing too much new complexity.