Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!agate!pasteur!ames!mailrus!uwmcsd1!nic.MR.NET!shamash!raspail!bga From: bga@raspail.UUCP (Bruce Albrecht) Newsgroups: comp.lang.fortran Subject: Re: Arrays and pointers Summary: pointer operations Message-ID: <364@raspail.UUCP> Date: 22 Sep 88 21:26:03 GMT References: <447@quintus.UUCP> <3826@lanl.gov> <1023@amelia.nas.nasa.gov> <1030@amelia.nas.nasa.gov> Organization: Control Data Corporation, Arden Hills, MN Lines: 23 In article <1030@amelia.nas.nasa.gov>, fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) writes: > You are thinking of how to misuse pointers. I am thinking of how to > correctly use them. Even Wirth, that bastion of safe-code, thought > that pointers were tame enough for Pascal and Modula-2. I can write > unmaintainable code using any facility (remember the GOTO debate and > how the first round was finally ended by Knuth's well reasoned when > to/ when not to paper?) or I can write elegant code, using any > facility. You're only partially right here. Very few strongly typed languages (and neither Pascal nor Modula-2 are in this category) have any pointer operations other than assignment and comparison. The pointer increment and decrement operations are the major reason why many people are against the way C uses pointers as a way to index through arrays. It's interesting that you compare the use of pointers to the use of GOTO. The argument against the GOTO is that unrestricted use of them tended to result in unreadable, unmaintainable code. I think that using pointer increment/decrement tends to produce the same result. It's more difficult to provide bounds checking in C if you are using pointers to traverse the array elements, and I suspect code is more obscure if the code is not accessing each element sequentially. Nearly any random access to an array is going to be more clearly represented using indices than by using pointers.