anything like C++ references?
intentionally at blank.co.uk
Sun Jul 13 23:41:20 CEST 2003
On Sun, 13 Jul 2003 17:16:08 -0400, "Terry Reedy" <tjreedy at udel.edu>
>> You could use the same argument to rationalise a language which used
>> the + operator to express subtraction.
>Bogus comparison with name binding. I am not aware that Python does
>anything quite so backwards.
Using an exaggeration as an analogy. Possibly. Though terms like
'assignment', 'variable' and 'value' seems pretty fundamental to me,
so the exaggeration is not that huge.
>> 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
>From what others have posted, Python is not the only language in which
>'name=object' means "assign 'name' to that object". This is much
>closer to the common idea of object having names than the idea that
>names can only name value holders (blocks of linear memory) and not
>values or objects themselves.
Many languages have *explicit* ways to create what computer science
calls pointers. Sometimes they have implicit dereferencing. Sometimes
they come prepackaged in a 'pointer to' or 'reference to' style
object. But the fact that you are dealing with something that
semantically behaves as a pointer is always explicit in some way or
Or rather, it should be. The fact that a few other languages are
broken in much the same way does not mean that Python is doing the
right thing. The right thing does not mean imitating Java or whatever
any more than it means imitating C++.
If you want a good example to imitate, though, look to Haskell. I
don't know how it binds variables to values, but I do know that in
general it can't a simple mapping from identifier to memory location.
Even so, I don't care. Why should I? The implementation of the binding
is irrelevant - I only care that the value bound to the variable is
the one that I specified and that it doesn't get changed behind my
More information about the Python-list