Is 'everything' a refrence or isn't it?
iko at cd.chalmers.se
Sun Jan 8 01:41:14 EST 2006
In article <mailman.166.1136661197.27775.python-list at python.org>,
Fredrik Lundh <fredrik at pythonware.com> wrote:
>> and the Python use is consistent with the rest of computer science.
>The problem isn't the word "reference" in itself, the problem is when people
>are implying that "since Python passes object references to functions, it's
>using call by reference".
Actually, I think the problem is not in the "call" bit. Python behaves
more or less like all other call by reference languages in the call. What
is confusing people is what happens when you *assign* to a function argument.
Those confused are expecting Python function arguments to behave just
like C++ references (which are just syntactic sugar for a dereferenced
pointer) or an Ada "in out" parameter when assigned. Python doesn't,
because in Python assignment assigns a new reference to the name,
rather than changing the referenced object.
-- Of course I'm crazy, but that doesn't mean I'm wrong.
Anders Hammarquist | iko at cd.chalmers.se
Physics student, Chalmers University of Technology, | Hem: +46 31 88 48 50
G|teborg, Sweden. RADIO: SM6XMM and N2JGL | Mob: +46 707 27 86 87
More information about the Python-list