Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.misc Subject: Re: Answers, Chapter 1: TeX (was C's sins... and others) Message-ID: <3656@lanl.gov> Date: 23 Oct 90 21:28:07 GMT References: <66253@lanl.gov> <14269@goofy.megatest.UUCP> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 32 In article <14269@goofy.megatest.UUCP>, djones@megatest.UUCP (Dave Jones) writes: > From article <66253@lanl.gov>, by jlg@lanl.gov (Jim Giles): > > ... There are _NO_ pointers in > > the source code for TeX 'packed array tries'. The code does everything > > through the use of Pascal arrays. > > For theoretical considerations, an index into an array is not much > different from a pointer is it? Range-checking is the only significant > difference I can think of, and that only makes incorrect programs > fail nicer. (Pointers also have some measure of range-checking, > "segmentation violation" for example. Never happened to *me* of > course, but I've heard rumors.) For thetheoretical considerations, pointers and one-dimensional arrays are indeed very similar. But the context of the discussion makes it clear that the person who posted TeX as an example of pointer efficiency was of the opinion that pointers and arrays differed importantly. In fact, in the same news article that he proposed TeX, he also gave examples which attempted to prove the supposed superiority of pointers to arrays. Of course, pointers and one dimensional arrays - in spite of their similarity - are indeed different. For one thing: arrays are bounded. For another: distinct arrays are generally not aliased. These two properties make debugging and maintaining array codes somewhat easier than pointer code. Similarly, these two differences (particularly the no-alias information) is useful to the compiler in generating more efficient code. After all, all the common optimization techniques that compilers use are inhibited to one extent or other by the possible presence of aliasing. J. Giles