News for hackers. Stuff that matters.
Re:Java is pass-by-value, Dammit (and so are Ruby and Python... by mattdawson on Sunday December 06, 2009 @10:55AM (#979673)
Python, for one, doesn't help to make the matter any clearer. In fact, Python makes it look like pass-by-reference is used, even when it isn't.

For a better explanation than I could ever come up with: http://stackoverflow.com/questions/986006/python-how-do-i-pa...

Just to play devil's advocate: if it looks like a duck and quacks like a duck, why would I call it anything other than "duck"? It may be technically correct to say that (in Python, at least) everything is passed by value. But if it helps someone remember that lists may be altered when passed to a function and that tuples can't, what's the real harm?

Again: devil's advocate.

Re:Java is pass-by-value, Dammit (and so are Ruby and Python... by olavk on Sunday December 06, 2009 @11:38AM (#979743)
It is just the terminology that is confusing, because the word 'reference' has a different meaning when talking about parameter passing semantics, than when talking about references to objects.

The Effbot suggest we call Python call semantics for 'call-by-object-reference' http://effbot.org/zone/call-by-object.htm which makes it a lot clearer.

Re:Java is pass-by-value, Dammit (and so are Ruby and Python... by enjo on Monday December 07, 2009 @03:19AM (#980908)
I think it's really important to understand why tuples can't be modified and lists can. If you explain it away with something factually incorrect about pass-by-reference, your doing a real disservice to whomever you are teaching.

After all, the issue here has nothing to do with parameter passing and everything to do with object design. It's important to understand that tuples are truly immutable and what the implications of that is.

Misuse of tuples and lists are one of the biggest problems I see in novice (and often not so novice) python code. How often do you see someone copying tuples (often inadvertently) when list semantics are far more efficient? That stems from a fundamental misunderstanding of immutability, something that might stem from not understanding how parameters are truly passed in the language.

Re:Java is pass-by-value, Dammit (and so are Ruby and Python... by scott_s on Sunday December 06, 2009 @06:02PM (#980309)
Because it means they don't understand what's going on in the language runtime. That is, it betrays ignorance.