Nested function scope problem

Antoon Pardon apardon at forel.vub.ac.be
Sun Jul 30 08:54:14 EDT 2006


On 2006-07-29, Gerhard Fiedler <gelists at gmail.com> wrote:
> On 2006-07-29 13:47:37, Antoon Pardon wrote:
>
>> I think the important thing to remember is that the assignment in Python
>> is a alias maker and not a copy maker. In languages like C, Fortran,
>> pascal, the assignment makes a copy from what is on the righthand and
>> stores that in the variable on the lefthand. In languages like Lisp,
>> Smalltalk and Python, the assignment essentially makes the lefthand
>> an alias for the righthand.
>
> Yes, I think I got it now :) 
>
> It seems that, in essence, Bruno is right in that Python doesn't really
> have variables. Everything that seems variable doesn't really change; what
> changes is that an element of what seems to change gets rebound.

Aren't you looking too much at implementation details now?

The difference between an alias assignment and a storage assigment
is for instance totaly irrelevant for immutable objects/values like numbers.

On a language level you can't distinghuish between immutable types
where the implementation uses storage assignment or alias assignment
and a number of language implementation do use different implementation
for different types because of optimisation considerations.

AFAIU, one can also build a C++ class hierarchy that with some small
limitations in used operators, would have semantics very similar to
Python. Would you argue that those using such a C++ class hierarchy would
no longer be using variables in C++?

-- 
Antoon Pardon



More information about the Python-list mailing list