git.net

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

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


Marko Rauhamaa <marko at pacujo.net> writes:

> Paul Rudin <paul.nospam at rudin.co.uk>:
>
>> Marko Rauhamaa <marko at pacujo.net> writes:
>>> The object is only an intermediate result; what is returned is a
>>> pointer (to an object), without an exception. That's not a matter of
>>> implementation. It's an essential part of Python's data model.
>>
>> Well - the language has no explicit notion of "pointer", [...] it's
>> better (IMO) to just talk in the terms the language specification
>> uses.
>
> The spec (<URL: https://docs.python.org/3/reference/datamodel.html>)
> uses the terms *identity* and *reference*, which are one-to-one.

identity isn't the same thing as a name, identity is an inherent
property of an object - many names may refer to the same object.

Similarly reference doesn't mean the same thing as identity. A reference
to an object can occur, for example:

["foo"]

The list refers to the string. There's no name involved anywhere. Both
the list and the string have an identity, but that's essentially
irrelevant to the fact that the list has a reference to the string.

>
>> There are names and objects, and mechanisms by which names come to
>> refer to objects according to the execution model.
>
> The spec as well as Python itself uses the word "name" for various
> strings:
>
>    >>> "x".__class__.__name__
>    'str'
>    >>> __name__
>    '__main__'
>

__name__ is not the same thing as what the spec means when it talks of a
name.

It's certainly true that a class declaration creates a binding from that
name to an object representing the class. But other names can equally
well refer to the same object:

>>> class Foo:
...     pass
... 
>>> Bar = Foo
>>> x = Bar()
>>> x.__class__.__name__
'Foo'
>>>

>
> So your "names" are *variables*.

Informally yes, but "variable" has no meaning in the language reference.

>
> Your "mechanisms" are *references*.
>

Nope - when I spoke of mechanisms I was talking about the different
operational semantics by which a given names can be bound to an object.

Once such an binding has occured then I agree that the name refers to
the object in question.

> Your "objects" are *objects*.
>

I think I probably agree, but I'm not sure what you're saying - "object"
means something in the language reference - that's what I'm talking
about.


>> Talk of pointers is potentially confusing, because it carries baggage
>> from other languages which doesn't necessary map precisely onto the
>> python execution model.
>
> Unfortunately, virtually every word is overloaded and full of
> preconceived notions. Hence: "pegs", "leashes", "puppies".
>
> The main thing is to keep those three concepts apart from each other.
> Two notions will not suffice.
>

Well - adding more things is confusing in IMO - we have a language
reference, let's just use the terms in the language reference.