passing by refference
Fredrik Lundh
fredrik at pythonware.com
Wed May 14 02:48:08 EDT 2003
Joshua Marshall wrote:
> See
>
> http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?call-by-value
>
> What you describe is call-by-value.
It's interesting that you quote FOLDOC, given that FOLDOC doesn't
refer to Python's model as call-by-value, as can be seen in the CLU
entry:
http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?CLU
"Arguments are passed by call-by-sharing, similar to
call-by-value, except that the arguments are objects
and can be changed only if they are mutable."
Note the use of the words "similar" and "except".
For a brief description of CLU's object and argument passing models,
see [1]. I think you'll find that it matches Python's model pretty well.
The CLU Reference Manual [2] by Liskov et al says (page 14):
"We call the argument passing technique _call by sharing_,
because the argument objects are shared between the
caller and the called routine. This technique does not
correspond to most traditional argument passing techniques
(it is similar to argument passing in LISP). In particular it
is not call by value because mutations of arguments per-
formed by the called routine will be visible to the caller.
And it is not call by reference because access is not given
to the variables of the caller, but merely to certain objects."
Note the use of "does not" and the repeated use of "it is not".
Let me emphasise:
"IN PARTICULAR IT IS NOT CALL BY VALUE because mutations
of arguments performed by the called routine will be visible to
the caller. And IT IS NOT CALL BY REFERENCE because access
is not given to the variables of the caller, but merely to certain
objects."
CLU was designed in the mid-seventies, and this reference manual
was published in 1979. In other literature, the CLU designers some-
times refer to this model as "call by object" [3], or they carefully
ignore the issue by talking about "objects" instead of values, and
"objects that refer to other objects" instead of references [1], but
I cannot find a single place where they've gone from "in particular
it is not call by value" to "it is call by value".
So what's your excuse for being stuck in the early seventies? ;-)
</F>
1) http://www.cs.berkeley.edu/~jcondit/pl-prelim/liskov77clu.pdf
2) http://www.lcs.mit.edu/publications/pubs/pdf/MIT-LCS-TR-225.pdf
3) http://www.lcs.mit.edu/publications/pubs/pdf/MIT-LCS-TR-561.pdf
More information about the Python-list
mailing list