From: why the lucky stiff Date: 2005-01-20T06:17:32+09:00 Subject: Re: value by reference 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. I think Ruby lacks this feature either because it's a scary change that could be misunderstood or because it's difficult to distill into a technique that fits within the current Ruby. 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. What I'm looking for is closer to a SymbolTable#sub!. Where I pass it two object IDs and every instance of the former becomes the latter. Better yet, a third object ID parameter would cause substitution only within the tree starting at that VALUE. It would be fine if this mechanism checked for ! BUILTIN_TYPE(obj) in the first call described above, but allowed builtin type subs within a tree. _why