Terminology: "reference" versus "pointer"

Steven D'Aprano steve at pearwood.info
Sat Sep 12 22:30:40 EDT 2015


On Sun, 13 Sep 2015 07:10 am, Random832 wrote:

> Jussi Piitulainen <harvesting at makes.email.invalid> writes:
>> I think the best way is to say that a[0] and a[1] are the same object,
>> while b[0] and b[1] are different objects.
> 
> Sure, you can *say* that. But how do you draw it on a diagram with
> sticky notes or parcel tags or whatever?

However you like. Invent your own notation. A few suggestions:


Colour coding:

Have a convention that objects drawn in black imply that object identity is
not important. That is, if you have two boxes drawn in black with the same
value, you are making no claim one way or the other whether they are the
same object or not. If, and only if, identity is important, then you give
each object a unique colour. So if the user sees five boxes containing the
value "foo", two in red, two in green, and one in black, they know that
there are at least two, and possibly three, but no more than three,
individual objects.

Shapes:

Likewise, except instead of colour, use the shape of the box to indicate
identity. A rectangular box means you say nothing about identity. Other
shapes (circle, oval, rhombus, trapezium, parallelogram, cloud-shape, etc.)
uniquely represents the individual objects.

IDs:

Write the object ID on each box, or at least the boxes where identity is
important. A good convention is that IDs start at 1.

Or, rather than show a numeric ID, use a symbolic ID: a, b, c, d, e would
reference five distinct objects.

Or, use non-alphabetical symbolic IDs: *†‡ would let you identify three
distinct objects. Add extra symbols as needed.


Astral travel:

According to those who believe in the astral plane, when you travel through
the astral plane, a silver thread connects your physical body to your
astral body. Or your earthly soul to your astral soul. Or whatever it is
that they believe. Use the same symbolism: if you have two or more boxes
representing the same object in different places, join them with a silver
thread. Or other colour of your choice. Perhaps a dotted or dashed line.

Hatch marks:

There is a convention in geometry to indicate lines of equal length with a
hatch mark (a small line perpendicular to the line itself). You can mark
the boxes which refer to identical objects using a similar convention.

Here is a crappy ASCII-art representation of various hatch marks on a
horizontal line:

----|----||----|||----/----//----\----\\----X----XX---->----<----

That is, reading from left to right:

- 1 to 3 vertical lines; 
- 1 or 2 lines slanted up to the right; 
- 1 or 2 lines slanted down from the left;
- 1 or 2 crossed lines;
- single right-pointing arrow;
- single left-pointing arrow.


If you limit yourself to no more than four hatch marks, taken from the set
of "|/\X<>", that gives you 1554 distinct markers. If you need to identify
more than 1554 distinct objects on one diagram, I suggest your diagram is a
tad too complex.



-- 
Steven




More information about the Python-list mailing list