Modifying Class Object
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Feb 14 10:11:19 EST 2010
On Sat, 13 Feb 2010 23:45:47 -0800, Steve Howell wrote:
> The term "pointer" is very abstract. Please give me a concrete
> definition of a pointer.
A programming language data type whose value directly specifies (or
"points to") another value which is stored elsewhere in the computer
memory.
I quote from Wikipedia:
http://en.wikipedia.org/wiki/Pointer_(computing)
[quote]
A pointer is a simple, less abstracted implementation of the
more abstracted reference data type
[end quote]
And later:
[quote]
While "pointer" has been used to refer to references in
general, it more properly applies to data structures whose
interface explicitly allows the pointer to be manipulated
(arithmetically via pointer arithmetic) as a memory
address...
[end quote]
And again:
[quote]
A memory pointer (or just pointer) is a primitive, the value
of which is intended to be used as a memory address; it is said
that a pointer points to a memory address. It is also said that
a pointer points to a datum [in memory] when the pointer's value
is the datum's memory address.
More generally, a pointer is a kind of reference, and it is said
that a pointer references a datum stored somewhere in memory; to
obtain that datum is to dereference the pointer. The feature that
separates pointers from other kinds of reference is that a
pointer's value is meant to be interpreted as a memory address,
which is a rather 'low-level' concept.
[end quote]
> A curly brace is one of these: { }
>
> Pretty concrete, I hope.
But { and } are glyphs in some typeface. Chances are that what you see,
and what I see, are quite different, and whatever pixels we see, the
compiler sees something radically different: two abstract characters
implemented in some concrete fashion, but that concrete fashion is a mere
implementation detail. They could be implemented as bytes x7b and x7d, or
as four-byte sequences x0000007b and x0000007d for UTF-32, or who knows
what in some other system. So the *concrete* representation of the curly
brace varies according to the system.
>From that, it's not a difficult leap to say that Pascal's BEGIN and END
key words are mere alternate spellings of the abstract "open curly brace"
and "close curly brace" with different concrete representations, and from
that it's a small step to say that the INDENT and DEDENT tokens seen by
the Python compiler (but absent from Python source code!) are too.
>> But reference also has a concrete meaning: C++ has a type explicitly
>> called "reference":
>>
>> http://en.wikipedia.org/wiki/Reference_(C++)
>>
>>
> Of course, "reference" has concrete meanings in specific contexts. But I
> can refer you to much more general and abstract uses of the term
> "reference." Do you want references? I will be happy to refer you to
> appropriate references.
I know that reference can also be used in the abstract. I'm just warning
that it can also be used in the concrete, and so we need to be wary of
misunderstandings and confusions.
>> And of course call-by-reference (or pass-by-reference) has a specific,
>> technical meaning.
>>
>>
> Which is what?
http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_reference
--
Steven
More information about the Python-list
mailing list