4 ms·
"It works just like Python"
by tedunangst 12y ago
"It works just like Python"
- rifung 12y agoI don't know if that'd help or hurt, I've definitely seen people also say Python is pass by reference. It seems like they have the same problem.
- _ZeD_ 12y agoStorically, python devs says the python language use "pass-by-name"
- icebraining 12y agoHow so? Reading [1] on pass-by-name, I don't see how it applies to Python, which evaluates the function arguments before passing them. The example given would be, in Python, def double(x): x *= 2 a = [4] double(a[0]) If Python was pass-by-name, a would now be [8], but it's actually still [4]. [1] http://www.cs.sfu.ca/~cameron/Teaching/383/PassByName.html http://www.cs.sfu.ca/~cameron/Teaching/383/PassByName.html
- ptx 12y agoExactly. Objects in Java work just like objects in Python: pointers passed by value. The difference is that everything in Python is an object, whereas Java additionally has primitive types where the value itself is passed by value.