From: Morton Goldberg Date: 2007-09-30T10:48:32+09:00 Subject: Re: a = Dog.new # a is not a pointer and not a reference? On Sep 29, 2007, at 8:18 PM, SpringFlowers AutumnMoon wrote: > Come to think about it, a pointer is very clear cut... an alias is > very > clear cut. but when it is "reference", then you have to think whether > it is the pointer behavior or the alias behavior. No, you do not. Ruby has it own semantics, which do not correspond 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. Try this. Without going into implementation details, of which I am ignorant, a Ruby variable establishes an association between an identifier and an object [*]. The association is specific to a particular lexical scope and to a particular execution extent. Therefore the same identifier can be associated (refer to) different objects in different scopes and different objects at different points of the execution. Such an association should perhaps more strictly be called a binding rather than a reference, but 'reference' is often used in informal discourse. This the way I think of it. It's an old Lisp programmer's point of view, but I think it's a reasonably good model for Ruby. It has worked well for me -- kept me out of trouble. And if I'm guilty of wrongly imposing Lisp semantics on Ruby, I'm sure I'll be corrected :) Regards, Morton [*] Yes, I know this is not the whole story. I'm trying to keep things simple.