S
SpringFlowers AutumnMoon
when we say
a = Dog.new("lulu")
Now a is not really a pointer, because we don't need to dereference it
to use it, like
(*a).color = "red"
a->color = "red"
When we use a.color, it is like a reference in C++ implicitly
dereference it and use its attributes.
But then a is not really a reference (like C++), because we can say
a = nil or a = Dog.new("woofy")
and now a points to some where else. With reference, once a reference
is set, it cannot point to some where else (in C++).
So it is kind of a mixture of pointer and reference?
Or, we can think of it as a pointer, and then think of "." as the "->"
in C++.
In that case, we can say that a is a pointer and not a reference.
And it seems the same way in Java, Python, and PHP5.
(Pointers and References discussed in
http://en.wikipedia.org/wiki/Reference_(computer_science)
http://en.wikipedia.org/wiki/Reference_(C++)
)
a = Dog.new("lulu")
Now a is not really a pointer, because we don't need to dereference it
to use it, like
(*a).color = "red"
a->color = "red"
When we use a.color, it is like a reference in C++ implicitly
dereference it and use its attributes.
But then a is not really a reference (like C++), because we can say
a = nil or a = Dog.new("woofy")
and now a points to some where else. With reference, once a reference
is set, it cannot point to some where else (in C++).
So it is kind of a mixture of pointer and reference?
Or, we can think of it as a pointer, and then think of "." as the "->"
in C++.
In that case, we can say that a is a pointer and not a reference.
And it seems the same way in Java, Python, and PHP5.
(Pointers and References discussed in
http://en.wikipedia.org/wiki/Reference_(computer_science)
http://en.wikipedia.org/wiki/Reference_(C++)
)