I'm wrong or Will we fix the ducks limp?
Op 08-06-16 om 18:37 schreef Marko Rauhamaa:
> Antoon Pardon <antoon.pardon at rece.vub.ac.be>:
>> You can do something like that in simula, but only because
>> simula has two kinds of assignments. One kind that is
>> simular to python and one that is similar to C.
>> The one that is similar that python is the reference assignment.
> I see Python as doing the exact same thing with variables as C.
> What is different is that in Python, every expression evaluates to a
> pointer. Thus, you can only assign pointers to variables.
Then you think wrong. Python has no pointers, that is an implementation
In python when you have two variables, and you assign one to the other
you then have two variables that share an object.
In C when you have two variables and you assign one to the other you
then have two variable each refering to their own object that are copies
of each other.
And yes that sharing of variables in python can be simulated by copying
pointers in C. Maybe the simularities between variables in python can be
made isomorphic with a specific subset of pointer operations in C.
The fact is that such an isomorphism would be limited to specific
pointer operations and would not extend to how variable generally
behave in C.
In a rather straight forward environment with classes/structs that
have an x and y attribute, the following lines behave differently
in C and Python.
A.x = 1;
A.y = 2;
B = A;
B.x = 3;
B.y = 4;
In C the variable A will still be x:1, y:2.
In Python the variable A will be x:3, y:4.
So no, Python doesn't do the exact same thing with variables as C.