Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!ark From: ark@alice.UucP (Andrew Koenig) Newsgroups: net.lang.c,net.micro.pc,net.unix Subject: Re: Fun with * and & Message-ID: <5694@alice.uUCp> Date: Mon, 23-Jun-86 15:20:16 EDT Article-I.D.: alice.5694 Posted: Mon Jun 23 15:20:16 1986 Date-Received: Wed, 25-Jun-86 03:32:43 EDT References: <1250@ncoast.UUCP> Organization: Bell Labs, Murray Hill Lines: 41 Xref: watmath net.lang.c:9561 net.micro.pc:8811 net.unix:8361 > 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.) But that's not how Algol 68 works. Instead, you write: REF INT pi; which says that pi is bound to a reference to a reference to an integer (less formally, a variable of type REF INT). You can also say: INT x; which defines x as an integer variable (formally a REF INT), and then: x := pi; which implicitly dereferences pi, or x := INT (pi); which explicitly dereferences it. The easy way to remember how C pointer declarations work is that int x; says that x is an int, and int *x; says that *x is an int, so x is a pointer to int.