On Tue, 2006-06-13 at 11:06 -0600, Shane Hathaway wrote: > Interesting. To me, the distinction between a pointer and a reference > is that a reference not only points to the object referenced but also > has some kind of strong link back to the thing that's referencing it. > That strong link backward is what makes garbage collection possible. In > the C++ code "int foo(int &bar)", the variable bar is just a cleverly > disguised pointer, not a reference in the usage I am accustomed to.
While this is one way of thinking about it, a far better way to think about it (one that will get you in less trouble) is to say that the variable passed by reference in C++ *is* the same variable. In other words, unlike python, java, etc, if you rebind the reference variable, it rebinds the original variable. They are the same. So a reference would be more like a pointer to a pointer plus syntactic sugar. > > I wonder which sense is standard? Is the meaning of "reference" > different depending on the language? Ugh, I hope not, but I bet it is. Time for me to go back and dig out my old cs 330 textbook and read up on it. But I think your right. Michael > > Shane > > > /* > PLUG: http://plug.org, #utah on irc.freenode.net > Unsubscribe: http://plug.org/mailman/options/plug > Don't fear the penguin. > */ > /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
