passing by refference
Aahz
aahz at pythoncraft.com
Fri May 16 14:37:44 EDT 2003
In article <873cjfbrxd.fsf at charter.net>,
Doug Quale <quale1 at charter.net> wrote:
>
>Argument passing in Java and C are no different from Python.
At the technical level, that's correct, provided you define "argument"
correctly. But because assignment does different things in Python, too
many Java/C programmers get confused with Python's semantics.
In C, you have this:
myStruct a, b;
a.x = 1;
b = a;
a.x = 2;
print ("%d\n", b.x);
There's simply nowhere in Python that assignment performs a value copy
that way. Using "value" to describe both the references to objects and
to the objects themselves is too confusing. Therefore "call-by-value"
is confusing and should be avoided when discussing Python.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles: boring syntax, unsurprising semantics,
few automatic coercions, etc etc. But that's one of the things I like
about it." --Tim Peters on Python, 16 Sep 93
More information about the Python-list
mailing list