Reference or Value?

Tim Rowe digitig at gmail.com
Tue Feb 24 09:19:56 EST 2009


2009/2/24 Steven D'Aprano <steve at pearwood.info>:

> If you look at this Wikipedia page:
>
> http://en.wikipedia.org/wiki/Evaluation_strategy
>
> you should be able to count no fewer than thirteen different terms for
> different evaluation strategies, and "call-by-value" itself is described as
> a family of strategies.

And that call by sharing is a member of that family even though the
behaviour is (as I understand it) exactly what you would get if you
pass an object by ^reference^ in C++. Wikipedia can be a double-edged
sword ;-).

I think the problem is that "Call by value" and "Call by reference"
are terms that pre-date object orientation, and don't cope well with
obect-oriented languages in general, not just with Python. That Java
programmers get by thinking the mechanism is called "call by value",
C++ programmers get by thinking the same mechanism is called "call by
reference" and Python programmers get by thinking the same mechanism
is called "call by sharing" suggests that the terms are no longer
helpful. Programmers in one language simply can't know what the
terminology means when applied to another language without learning
the behaviour in that other language before learning the terminology.

That means that Torsten's original question probably wasn't the one he
wanted to ask, and wasn't a useful one. The useful question is "what
is Python's parameter passing *behaviour^",
with a possible supplementary "what do they call that behaviour *in
the Python community*", recognising that if they asked "what is Java's
parameter passing *behaviour^",
with the supplementary "what do they call that behaviour *in the Java
community*" they would get much the same answer for the first question
(immutability is handled differently, I think, but it's there) but a
totally different answer to the second.

-- 
Tim Rowe



More information about the Python-list mailing list