On Thu, 27 Jan 2005, Trans wrote: > It was mentioned the previous thread that purely pass-by-value is > arguably the most "proper". But as we all know it is inefficient > --having to copy an object going in only to turn around and reassign it > whence it came: > > a = amethod(a.dup) Actually, you need pass by reference for arguments where you want the function to have side-effects affecting that argument. I think a much better way of getting the kind of "reliability" you're talking about is to always pass by reference, but wherever you can, use value objects. Methods that would "modify" a non-value object instead return a new value object with the modified state. For example, p1 = Point.new(17, 35); p2 = p1; p1 = p1.move(0, 5); Now p2 still refers to the point (17,35), but p1 has been changed to refer to a different point (17, 40) (rather than the point itself changing). This helps greatly to avoid aliasing. Avoiding side-effects as much as possible in this way is OO in sort of a functional programming spirit. One of the things I think Java did right was to make Strings immutable. One of the things I think Java did wrong was to make Dates mutable. cjs -- Curt Sampson <cjs / cynic.net> +81 90 7737 2974 http://www.NetBSD.org Make up enjoying your city life...produced by BIC CAMERA