assigning values in python and perl
Antoon Pardon
apardon at forel.vub.ac.be
Tue Jan 22 07:23:32 EST 2008
On 2008-01-17, Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> wrote:
> On Thu, 17 Jan 2008 11:40:59 +0800, J. Peng wrote:
>
>> May I ask, python's pass-by-reference is passing the object's reference
>> to functions, but perl, or C's pass-by-reference is passing the variable
>> itself's reference to functions. So althought they're all called
>> pass-by-reference,but will get different results.Is it?
>
> Python is not call by reference.
>
> Any book or person that says it is, is wrong to do so.
>
> Python's function call semantics are not the same as C, or Perl, or
> Pascal. They are, however, similar to those of Lisp, Scheme, Emerald and
> especially CLU. It is neither pass by reference, nor pass by value.
I don't think it is the function call semantics that are so different
as it is the assignment itself that is different.
an assignment in C, doesn't bind a new object to the name, but
stores new information in the object.
Trying to explain the different behaviour of C and python of
examples calling function that assign to a parameter, without
explaining how the assignment works will IMO not give people
enough to understand what is happening.
--
Antoon Pardon
More information about the Python-list
mailing list