🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #17

Re: Pointers in ALGOL

#17
From: John Haxby
Date: Thu, 29 Oct 1992 11:37
35 lines
1586 bytes
In article <chl.720269838@cs.man.ac.uk>, chl@cs.man.ac.uk (Charles Lindsey) writes:
	[text about triple-ref]

|> You can't do this sort of thing in Pascal, but you can do it in C if you are
|> VERY careful.

Indeed, there is the right way:

	struct foo **ptr = &start;
	while (*ptr != NULL)
		ptr = &((*ptr)->next);

and the wrong way:

	struct foo **ptr = &startl
	while (*ptr != NULL)
		*ptr = (*ptr)->next;

the small difference between these is obvious in Algol 68, but in
C you might happily spend half a day wondering why the wrong
way is sucessfully destroying perfectly good lists.

Incidentally, to product the right way originally, I had to puzzle
over the Algol68 version which I knew worked and which I understood,
when I wrote the wrong way in Algol 68 I knew why it didn't work.

C's pointers are a pain in the neck sometimes.

-- 
John Haxby, Definitively Wrong.
Digital				<jch@rdg.dec.com>
Reading, England		<...!uknet!wessex!jch>

----------------------------------------------------------------
The opinions expressed herein are my own, not my employers.
Technical Details
Message-ID: <1992Oct29.113733.3956@rdg.dec.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!haven.umd.edu!decuac!pa.dec.com!rdg.dec.com!jch
References: <BwqwKt.AGI@nic.umass.edu> <1992Oct27.080658.28422@arb-phys.uni-dortmund.de> <chl.720269838@cs.man.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!haven.umd.edu!decuac!pa.dec.com!rdg.dec.com!jch
From: jch@rdg.dec.com (John Haxby)
Newsgroups: comp.lang.misc
Subject: Re: Pointers in ALGOL
Message-ID: <1992Oct29.113733.3956@rdg.dec.com>
Date: 29 Oct 92 11:37:33 GMT
References: <BwqwKt.AGI@nic.umass.edu> <1992Oct27.080658.28422@arb-phys.uni-dortmund.de> <chl.720269838@cs.man.ac.uk>
Sender: news@rdg.dec.com (Mr News)
Organization: Digital Equipment Corporation
Lines: 35