Call by binding [was Re: [Tutor] beginning to code]

Chris Angelico rosuav at gmail.com
Mon Sep 25 10:39:36 EDT 2017


On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> On Mon, Sep 25, 2017 at 7:41 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> In Python, all expressions evaluate pointers.
>>
>> And that's an assertion that isn't backed by anything in the Python
>> specification. Where do you get that all Python expressions are
>> pointers?
>
> That's not what I said. I said all expressions *evaluate to* pointers.

Sorry, that was my bad in the terminology. But where do you get that
all Python expressions evaluate to pointers?

> As for the specification, it doesn't make use of the word "pointer:"
>
>    <URL: https://docs.python.org/3/reference/simple_stmts.html#assignme
>    nt-statements>
>
> Instead, it uses (English) expressions like:
>
>    is bound to the object
>    is rebound
>
> when talking about "names" (aka variables).

Yeah exactly. It doesn't say anything about them being pointers.
Because they aren't.

> It also uses circular definitions when talking about dicts and lists:
>
>    That object is then asked to assign the assigned object to the given
>    attribute
>
>    the sequence is asked to assign the assigned object to its item with
>    that index.

Technically, that's correct. When you use a statement like:

foo[bar] = quux

what it does is ask the object *foo* to assign *quux* to the item
represented by *bar*.

> The (English) expression:
>
>    The name is bound to the object.
>
> is just another way of saying:
>
>    A pointer to the object is stored in the variable.

Where does this come from? If the name "Rosuav" refers to me, does
that mean, in English, that there is a pointer to me stored in the
variable named "Rosuav"? English isn't implemented in C or Pascal.

> Of course, I'm using terminology that is not conventional in Python
> circles. However, I'm doing it to demonstrate that there's nothing
> particularly different between Python's assignment semantics and those
> of, say, Pascal. Python's assignment semantics are wholly contained by
> those of Pascal.

As long as you start by defining everything in terms of Pascal, yes,
you can then prove that everything is contained in Pascal semantics.
But you have yet to show how you can jump from "name binding" to
"pointer" using anything from the Python documentation.

ChrisA



More information about the Python-list mailing list