When you pass a parameter by value, it simply copies the value inside the function parameter, and everything that is done with this variable inside the function does not reflect the original variable, for example.
foo(a, b, c) { b =b++; a = a++; c = a + b*10 } X=1; Y=2; Z=3; foo(X, Y+2, Z);
but when we send the parameters by reference, it copies the address of the variable, which means everything that we do with the variables inside the function is actually executed in the original memory location, for example.
foo(a, b, c) { b =b++; a = a++; c = a + b*10 } X=1; Y=2; Z=3; foo(X, Y+2, Z); print X; //prints 2 print Y; //prints 5 print Z; //prints 52
to pass by name; Pass-by-name
nommyravian
source share