Mutability of function arguments?

Fredrik Lundh fredrik at pythonware.com
Thu Dec 8 12:17:07 EST 2005


Mike Meyer wrote:

> Your description of "passes references by value" is a description of
> call by reference. C passes all arguments by value, to pass a
> reference, the C programmer creates the reference to the value "by
> hand", then dereferences it by hand at the other end. So C's
> "call-by-reference" passes the reference by value. There's no
> difference between C's call-by-reference and Python's
> call-by-reference, and using different words to try and imply there is
> will just cause problems further on.

can you guys please stop using "call by value" and "call by reference"
when you discuss Python.  both terms have established meanings, and
Python's argument passing model doesn't match any of them.

this was known some 30 years ago; here's a quote from a CLU reference
manaual from 1979:

    "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."

(CLU was one of the first languages to use objects in the Python sense,
as well as the same argument passing model as today's Python)

established terms for Python's argument passing model are

    call by object

or

    call by sharing

for more on this, see the comp.lang.python archives.

</F>






More information about the Python-list mailing list