Who modified my local variable?
Ross Werner
ross at indessed.com
Tue Jun 13 21:54:27 MDT 2006
On Tue, 13 Jun 2006, 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.
I got to this thread kind of late, but just wanted to throw in my .02 USD.
-----Psuedocode-----
// ...
foo(x);
// ...
function foo(x) {
x = y;
}
-----End Pseudocode-----
If you can modify a variable inside a function by using the assignment
operator, then it's pass by reference. If using the assignment operator
*doesn't* modify the variable, then it's pass by value.
Hence, Java is always pass by value (which makes perfect sense to me). C
is also always pass by value unless you use the '&', in which case it's
pass by reference (because at that point, using the assignment operator
inside the function does modify that passed-in variable.
~ Ross
More information about the PLUG
mailing list