News for hackers. Stuff that matters.
Re:Java is Pass-by-Value, Dammit by tedunangst on Sunday March 22, 2015 @01:53AM (#9245765)
"It works just like Python"
Re:Java is Pass-by-Value, Dammit by ptx on Sunday March 22, 2015 @04:29PM (#9248094)
Exactly. 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.
Re:Java is Pass-by-Value, Dammit by rifung on Sunday March 22, 2015 @02:48AM (#9245894)
I 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.
Re:Java is Pass-by-Value, Dammit by _ZeD_ on Sunday March 22, 2015 @03:43AM (#9245972)
Storically, python devs says the python language use "pass-by-name"
Re:Java is Pass-by-Value, Dammit by icebraining on Sunday March 22, 2015 @06:13AM (#9246237)
How 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