Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon Allbery) Newsgroups: net.lang.c,net.micro.pc,net.unix Subject: Fun with * and & Message-ID: <1250@ncoast.UUCP> Date: Sun, 22-Jun-86 17:20:40 EDT Article-I.D.: ncoast.1250 Posted: Sun Jun 22 17:20:40 1986 Date-Received: Wed, 25-Jun-86 03:25:29 EDT References: <487@cubsvax.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: net.lang.c Organization: North Coast Computer Resources Lines: 30 Xref: watmath net.lang.c:9559 net.micro.pc:8809 net.unix:8359 Expires: Quoted from <487@cubsvax.UUCP> ["Re: C'mon, guys! (Really, pointer pedagogy)"], by peters@cubsvax.UUCP... +--------------- | 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. Somehow | it made thinking about the declarations easier. It's occurred to me that maybe | everyone else in the world sees this from day 1, but for us dumb folks, having | this reading pointed out would probably make the learning process easier.... +--------------- Easy: Use the Algol 68 method. (Snide remarks about sh and adb source to /dev/null or /dev/bourne, please.) Translate * as ``REF''. Then they look like: int *pi; -> int REF pi; x = *pi; -> x = REF pi; REF is, of course, short for ``reference'', which is just another word for ``pointer''. (Note that ``x = *pi'' is really a DEREFERENCE, since you're not merely using the ``refrence'' to the interger, but the integer itself. That's the confusion of C. ``*'' -> ``REF'' is a way to remember it.) --Brandon -- ihnp4!sun!cwruecmp!ncoast!allbery ncoast!allbery@Case.CSNET ncoast!tdi2!brandon (ncoast!tdi2!root for business) 6615 Center St. #A1-105, Mentor, OH 44060-4101 Phone: +01 216 974 9210 CIS 74106,1032 MCI MAIL BALLBERY (part-time)