Michael Ulm wrote:
> Dave Burt wrote:
> 
>> n = Matrix.I(2)
>> some_function(n)
>> p n # same as before
>> 
>> It's a good feature.
> 
> You are right, this is a somewhat useful feature (I've been bitten often
> enough by mutated Arrays). However, this only works as long as 
> some_function
> is not a third party application (or calls a third party library).
> 
> So it's a balance of conveniences. For me, the usefulness of []= far
> outweighs any advantages of the present implementation.
> 
>> 
>> []= would be useful, too, but I think to keep the immutability a better
>> addition that provides the same functionality could be provided; a
>> modified_at(x,y,value) method or something, but naming it is hard.
>> 
> 
> Then the whole Matrix would have to be copied to change one value --
> goodbye performance.


How about using an alternative to subclassing (similar to  the
"Alternative to inheriting from Array",
 http://www.bigbold.com/snippets/posts/show/2573 )?


-- 
Posted via http://www.ruby-forum.com/.