Terminology: "reference" versus "pointer"

Akira Li 4kir4.1i at gmail.com
Mon Sep 14 19:24:32 CEST 2015


Steven D'Aprano <steve at pearwood.info> writes:

> On Mon, 14 Sep 2015 01:23 pm, Akira Li wrote:
>
>> Steven D'Aprano <steve at pearwood.info> writes:
>> 
>>> On Mon, 14 Sep 2015 11:22 am, Akira Li wrote:
>>>> Look at the last example:
>>>> http://thread.gmane.org/gmane.comp.python.general/782626/focus=782704
>>>
>>>
>>> I'm afraid that page is broken in my browser. Can you not summarise, or
>>> link to the specific message? I may be able to use another browser in a
>>> day or two, but hopefully the discussion will have moved on by then.
>> 
>> https://mail.python.org/pipermail/python-list/2015-September/696631.html
>
> Thanks. You mean this example?
>
>   lst = [range(1, 3) for _ in range(3)]
>   a = [lst[0], lst[0]]
>   b = [lst[1], lst[2]]
>
>
> I don't see what's difficult about this example. Here's a simple ASCII
> drawing:
>
>
> lst --------> [ range-object-1 , range-object-2 , range-object-3 ]
>
> a ----------> [ range-object-1 , range-object-1 ]
>
> b ----------> [ range-object-2 , range-object-3 ]
>

I should have mentioned that lst plays the role of range-object-X in
your diagram i.e., only *a*, *b* names actualy exits (I should add `del
lst` to the example) -- as the original example requires.


> Trying to draw an arrow diagram using text is not my idea of a good time,
> but I'll give it a go. Requires a monospaced font and an email client that
> won't reflow the text:
>
>       +-----+------+
>       |     |      | <--------------------------- a
>       +--|--+---|--+
>          |      |
>          |      |
>          V      |
>       +-----+ <-+             +----+
>       |range| <---------------|-   |<------------ lst 
>       +-----+                 +----+
>                   +-----------|-   |
>       +-----+     |           +----+
>   +-> |range| <---+    +------|-   |
>   |   +-----+          |      +----+
>   |                    |
>   |   +-----+          |
>   |   |range| <--------+
>   |   +-----+
>   |      ^
> +-|-+    |
> |   |    |
> +---+    |
> |  -|----+
> +---+
>   ^
>   |
>   +------------------------------------------- b
>
>
> Out of the two, I know which one I prefer.

I don't know what it means. If you mean "box and arrows" is superior
somehow then I don't see any difference from the "parcel tags" model
here.

My point is that neither models are detailed enough to describe
meaningfully the behavior of Python code in the general case.



More information about the Python-list mailing list