Submitted by Sean (not verified) on Tue, 21/08/2007 - 09:28.
This is not true, Java _always_ passes by value. But if the parameter is an Object, you are passing the address of the Object (i.e. the reference) by value (you certainly don't copy the entire object onto the stack). Thus you are passing a reference by value.
Therefore, if you send the object a message (e.g. call a method on the Object) that changes its state, then this is observable outside the method body. But if you assign to the parameter within the method, you do not affect the caller's reference (it will still point to the same Object). And it sounds like Python works the same way.
This is not true, Java
This is not true, Java _always_ passes by value. But if the parameter is an Object, you are passing the address of the Object (i.e. the reference) by value (you certainly don't copy the entire object onto the stack). Thus you are passing a reference by value.
Therefore, if you send the object a message (e.g. call a method on the Object) that changes its state, then this is observable outside the method body. But if you assign to the parameter within the method, you do not affect the caller's reference (it will still point to the same Object). And it sounds like Python works the same way.