From: Austin Ziegler Date: 2005-01-20T01:55:43+09:00 Subject: Re: value by reference On Thu, 20 Jan 2005 01:01:01 +0900, trans. wrote: >> sorry if this offends, but there is no less blunt way to say it. >> if anyone need it. they've gone wrong already. the solution: >> design > That's silly. By that line of reasoning, nearly every other > language has got it wrong. Wrong must be pretty good since Ruby is > no where near as popular as those languages that can do this sort > of thing. No, it's not silly. Consider that C didn't have reference arguments until late in life (I don't remember offhand whether it's mentioned in my K&R'89 covering ANSI C). You had to use pointers -- and references came about because pointer math was simply asking for trouble. You needed this because C couldn't return more than one value from a function (usefully). Ruby isn't constrained the way that C was, needing pointers and references the same way. > I think the problem with Ruby is that it _can be done_ if you use > certain _types_ of objects, but not others. That to me goes > against the feather of our friendly duck. WRONG. Wrong in every way. Some objects permit the in-place modification of parts of their state. Others do not. Just because you can do: a << i if "a" refers to an Array, String, or other objects where #<< is defined doesn't make it a special exception. #<< isn't assignment; it's appending. a += i *is* assignment, and it follows the very *clear* rules that Ruby has for variables and objects. #+ is supposed to add two object instances together into a third object, not modify one of the objects in place. Convention? You bet. But it's consistent, at least, which is more than can be said for most of those languages that need call-by- reference. It also has NOTHING to do with duck-typing or POLS. Stop misusing those terms. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca