"always passes by reference"

Donn Cave donn at oz.net
Wed Jul 26 01:22:58 EDT 2000


Quoth weeks at golden.dtc.hp.com ((Greg Weeks)):
| Once upon a time, "pass by reference" meant that a function call f(x) could
| modify the binding of the variable x.  With this definition, "pass by
| reference" effectively passes the address of the variable x to the
| function.  "pass by value", by contrast, passes only the value of the
| variable x, not its address.
|
| With these definitions, Python is uniformly "pass by value".  So are Lisp,
| Java, and C, but not C++ and Perl.

I don't know about that.  But I see enough objections and amendments
have been contributed already to send this one far out to sea, so
I'll just add the observation that in Python usage, everything is
by "reference".  Any time an object is engaged in the program, it's
through what we call a reference.

The fact that a function call creates and passes these references
is really a red herring, because it doesn't matter how they get
there, by function or by import or whatever.  What you see is
always a reference, and operations on that reference have the
same implications in every case.

	Donn Cave, donn at oz.net



More information about the Python-list mailing list