From: Ian Whitlock Date: 2007-09-30T11:26:00+09:00 Subject: Re: a = Dog.new # a is not a pointer and not a reference? SpringFlowers AutumnMoon wrote: > > Doesn't a Ruby variable behave the same way in Java, PHP5, C++, and > Python? No. Well, yes, to the extent that variables in all these languages allow the values of variables to vary, but that is too simple a view to be useful beyond an introduction to programming. > > As long as I view Ruby as a pointer to an object, everything clicks. > Well it it works for you fine, but for many it has problems. Languages which have variables called pointers have values which are addresses and some way to reference the object at the address value. In other words, the concept of pointer carries with it the baggage that there will be two ways to "evaluate" the variable - as an address or as an object. Ruby variables cannot be evaluated to addresses, hence it is rather misleading to most people to use the term pointer for a Ruby variable. For example, in any language with pointer, p, it is reasonable to ask in that programming language, what is the address obtained from p by adding 8 bytes. There is no way to write this in Ruby. So if you find it helpful and wish to say that some of the purpose of variables in Ruby is served by some of the functions of some pointers in languages with pointers, I doubt if any rubist would disagree. But if you say Ruby variables are pointers in other languages, they are likely to reply,"Rubbish", because Ruby does not want to require the low level bookkeeping that pointers imply. Ian Whitlock -- Posted via http://www.ruby-forum.com/.