git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I'm wrong or Will we fix the ducks limp?


Op 06-06-16 om 05:52 schreef Steven D'Aprano:
> On Mon, 6 Jun 2016 03:42 am, Random832 wrote:
>
>> On Sun, Jun 5, 2016, at 02:37, Steven D'Aprano wrote:
>>> No they don't. You are confusing the implementation with the programming
>>> model.
>>>
>>> Following the assignment:
>>>
>>> x = 99
>>>
>>> if you print(x), do you see something like "reference 0x12345"? No.
>>>
>>> Do you have to dereference that reference to get the value of x? No.
>>>
>>> At the Python level, the value of x is 99, not some invisible,
>>> untouchable reference to 99.
>> Sure, but that is the value of the object referenced by x, it is not a
>> property of x itself.
> You need to be clear about what you are referring to.
>
> x itself is the object 99. When we say "x + 1", we expect to get 100. x is
> not some reference to 99, it is 99, just like Barrack Obama is not a
> reference to the President of the United States, he is the POTUS.

x is not the object 99. x is a variable that refers to an object that
has the value 99. That python starts looking for that object and
uses its value when your do arithmatics doesn't contradict that variables
refer to objects.

A reference is not pointer. When you use a reference parameter in Pascal,
it behave like an ordinary parameter within the procedure block, you don't
have to treat it like a pointer.