2 ms·
That, and I don't think there is a real consensus on the nomenclature, even in the literature. At least, I don't remember university lectures being at all clear
by gvx 8y ago
That, and I don't think there is a real consensus on the nomenclature, even in the literature. At least, I don't remember university lectures being at all clear on the issue.
FWIW, I don't use pass-by-value or pass-by-reference to refer to languages like Java, Python, Lua, etc... Instead, I use "pass-by-object-identity" (aka "call-by-sharing", "call-by-object") to refer to the semantics of those languages. It avoids the association many people have between the term "by-value" and copying behaviour.
Also part of the problem: many beginning and intermediate programmers don't understand the difference between rebinding and mutation. This leads to people interpreting the following snippet:
def foo(a, b):
a = 2
b.append(3)
x = 1
y = []
foo(x, y)
print(x, y) #1, [3]
... as meaning that ints are passed by value and lists by reference, while in fact both are passed by object identity, and it is the fact that a is rebound while b is mutated that made the difference.