Re: a = Dog.new # a is not a pointer and not a reference?




On Sep 30, 2007, at 10:54 PM, Austin Ziegler wrote:

Conceptually, they're better seen as labels or sticky notes. Maybe not
for the implementers, but definitely at the normal programmer's level.
Thinking about them more than that is just asking for madness because
you can't interact with them at any other level than that.

I can see the value of the sticky note analogy but I think it
obscures the idea of scopes. It puts the variable name in close
proximity to the referred object and not the referring scope.

Think about instance variables, for example. You can have two
objects each with an instance variable that has a reference to
a common third object:

class Foo
attr_accessor :other
end

alpha = Foo.new
beta = Foo.new

gamma = Object.new

alpha.other = gamma
beta.other = gamma

Does it make sense to think of gamma as having two sticky notes
with '@other' written on them? Not to me at least.

The problem with the sticky note analogy, for me, is that it implies
that the object has access to the sticky notes--that the object
can 'see' what variables are referring to itself. The notes seem
to be 'stuck' to the wrong thing in my mind. They should be more
like a piece of paper with a name and a phone number written on it.
The name is the variable and the phone number is the reference for
the other person (object). The phone system is an opaque system
that provides a way for us to contact another person and
communicate with them (send a message to another object) without
us having to know where that person is physically located.

Gary Wright


.



Relevant Pages


Loading