From: Gary Wright Date: 2007-09-30T03:46:33+09:00 Subject: Re: a = Dog.new # a is not a pointer and not a reference? On Sep 29, 2007, at 2:12 PM, SpringFlowers AutumnMoon wrote: > Morton Goldberg wrote: >> On Sep 29, 2007, at 1:16 PM, SpringFlowers AutumnMoon wrote: >> >> I think it best to think of a Ruby variable as holding a reference to >> an object. Ruby's reference semantics are different from C++'s, but >> IMO more mainstream. C++'s reference semantics are peculiar, to say >> the least, and perhaps even unique [*]. Ruby's variable semantics are >> simple and clean when compared to C++, so I recommend forgetting >> about making such comparisons. > > hm... so you mean best to think of a Ruby variable as holding a > pointer > to an object? I hope either > > 1) we use the word "reference" to mean a pointer > 2) or, we just use the word pointer instead, I think that 'pointer', for most programmers, means an explicit memory address. Ruby references should not be understood as explicit memory addresses but instead as opaque values that are processed by the underlying Ruby implementation as necessary to locate or 'reference' the associated object. At the level of a Ruby programmer I think it is best to discard the idea of 'pointer' entirely and think entirely about references to objects. At the level of a Ruby language implementor it becomes necessary at some point to discuss how a Ruby reference can be converted to a pointer to a chunk of memory, but that is an implementation detail that shouldn't concern a Ruby application programmer. Gary Wright