C'mon, guys! (Really, pointer pedagogy)
Peter S. Shenkin
peters at cubsvax.UUCP
Sun Jul 6 03:31:50 AEST 1986
In article <edison.811> jso at edison.UUCP (John Owens) writes:
>In article <487 at cubsvax.UUCP>, peters at cubsvax.UUCP writes:
>> Just a quick remark. When I was learning C, I understood that "*pi"
>> meant "the contents of pi," but somehow had difficulty conceptualizing
>> why the declaration "int *pi;" declares pi as a pointer to an int;
>> that is, I knew it was a convention I had to memorize, but it didn't
>> seem mnemonic to me. Then, about a month ago, revelation!: read this
>> as "the contents of pi is an integer;" which implies, "pi is that
>> which contains (or points to)" an integer.
>> Peter S. Shenkin Columbia Univ. Biology Dept., NY, NY 10027
>
>Maybe it's my machine-language heritage showing, but I've always found
>it least confusing to think of "pi" as "the contents of pi" (which is
>a pointer), "*pi" as "that which (the contents of) pi points to",
>"int i" as declaring i to contain an int, and "int *pi" as declaring
>pi to contain a pointer to an int.
>
Like many revelations of mine, I just discovered that this one was right
there in K&R from the first; "...I guess I was too young / to realize...":
p90: int *px;
is intended as a mnemonic; it says that the combination *px is
an int...
I also note with amazement that I used the word "mnemonic," which also
occurs in this K&R passage, in my original posting. I rarely use that
word, yet I hadn't read that section of K&R for about two years (that I can
recall) and its purport evidently eluded me at the time. People have
been accused of plagiarism for less....
Peter S. Shenkin Columbia Univ. Biology Dept., NY, NY 10027
{philabs,rna}!cubsvax!peters cubsvax!peters at columbia.ARPA
More information about the Comp.lang.c
mailing list