From: SpringFlowers AutumnMoon Date: 2007-09-30T15:39:35+09:00 Subject: Re: a = Dog.new # a is not a pointer and not a reference? Morton Goldberg wrote: > On Sep 29, 2007, at 10:17 PM, SpringFlowers AutumnMoon wrote: > >>> with the semantics of C or C++. Trying to impose the semantics of >>> other languages onto Ruby isn't going to work. It's best to drop such >>> baggage and start fresh. >> >> hm,... but is there a problem to think of reference in Ruby as a >> "pointer"? will that cause any trouble? I only see that >> a.value is >> not the same as C and C++ would use a->value, but in Ruby we use >> the "." >> to replace the "->" and that's it. Will there be further trouble or >> discrepancy to think of Ruby reference as a pointer? > > Well, your assertion that a.value is the equivalent of a->value is a > good example of getting into trouble by equating a reference to a > pointer. The expression a.value is a method call, not a value fetch. > For a.value to work, the object referred by a has have a method > called 'value', either an instance method or singleton method, in its > extended object table. If it does, the method is executed and some > object is returned. That's not at all what a->value does in C. how about just a.set_value(3) vs a->set_value(3). what i mean is just the "." and "->" difference. using a "." in Ruby and "->" in C or C++. If I think of "a" as a pointer and "." as "->", will that get in trouble and have any discrepancy for other things. -- Posted via http://www.ruby-forum.com/.