From: "Thomas B." Date: 2008-09-06T23:26:30+09:00 Subject: Re: Request: arguments by reference Pedro Silva wrote: > The main need for references is to allow primitive/immutable types to be > treated "as objects". Even if the only thing that Ruby used to implement > references was the object encapsulation, at least you have that option > and don't need to be doing that all the time it needs to be done. Being > inside Ruby it would be certainly faster than user made code. If you > think in C pointers or C++ references that's what they really are - > "capsules". I think it's preferable to have this option even if it isn't > as performant, but the programmer has the choice. So I think that the best solution could be not to add syntax for passing by reference, but to add types like MutableFixnum (and others), that would behave exactly like Fixnum, plus they would have method replace, working a bit like Array#replace - changing the value without creating a new object. In this way, all old code would work as before, and as fast as before, and also there would be no chance of accidentally changing value of an object that should not be changed (like calling a.b.replace(x) even though a.b= is not defined and it is crucial for the program that it is not). You would be able to change only object declared as MutableSomething. It wouldn't also mess things up with =. Probably not in 1.9, but maybe later it could make some sense to think about how to implement it in the core. Th. -- Posted via http://www.ruby-forum.com/.