anything like C++ references?
intentionally at blank.co.uk
Sun Jul 13 21:39:56 CEST 2003
On Sun, 13 Jul 2003 15:07:23 -0400, "Terry Reedy" <tjreedy at udel.edu>
>How a particular interpreter performs name binding is its own
>business, as long as the specified semantics are implemented.
You could use the same argument to rationalise a language which used
the + operator to express subtraction.
The fact is that 'assignment' has a common meaning separate from the
choice of programming language, and that the way Python handles name
binding means that meaning is not respected by Python for mutable
>What any computer does is
>probably significantly different from what human interpreters do.
And using references with a copy-on-write or lazy-assignment system is
different to immediate copying of values, but that is irrelevent as
both systems respect the common meaning of assignment.
Python, however, does not respect this meaning. It uses an arbitrary
distinction based on whether or not the object has internals that can
be usefully in-place modified, and uses that distinction to vary the
effect of assignment in an arbitrary, inconsistent and error-prone
way. The need for a distinct tuple type is a symptom of the arbitrary
nature of this.
I've already posted too much on this, so this is going to be the end
to it. But Pythons semantics with regard to mutable and immutable
objects are simply bizarre. A historic justification may be plausible
and backward compatibility is then an important issue, but I really
cannot accept claims that Python is doing the right thing here.
More information about the Python-list