Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!lanl!lambda!jlg From: jlg@lambda.UUCP (Jim Giles) Newsgroups: comp.lang.misc Subject: Re: C Pointers (was: Relationship between C and C++) Message-ID: <14282@lambda.UUCP> Date: 22 Mar 90 00:35:26 GMT References: <14823@pur-ee.UUCP> Lines: 38 From article <14823@pur-ee.UUCP>, by hankd@pur-ee.UUCP (Hank Dietz): > [...] The only aspects in which C pointers are harder to > analyze than Fortran array references are: > > [1] C pointers can be multi-level, i.e., pointers-to-pointers. > [2] C supports recursion, hence pointers/subscript expressions can be > more difficult to decipher. And: [3] C pointers might be aliased while Fortran arrays are not. This makes a more significant difference to optimization than your two points combined. This is why C still tends to be slower than Fortran on most scientific applications. Aside from this, I don't like pointers because they are too low level. I don't use GOTOs if a language provides high-level control structures that are adequate to my needs. I don't use pointers for the same reason. If my algorithm manipulates arrays, that's the appropriate data structure to use - NOT pointers. C, Pascal, and Modula all make the mistake of not allowing procedures to take array arguments of arbitrary size. C's pointers are an undesireable 'hack' to get around this constraint. The cost is that ALL array args to procedures are turned into pointers by the procedure interface - not at all desireable because of [3] above! J. Giles > > I think we can agree that [2] is desirable despite this. IMHO, [1] wouldn't > be needed if C would allow first-class declarations of parameterized types, > e.g., "int a[n];" where n is a variable... but lacking that, even [1] isn't > very offensive to me. > >>Preston Briggs looking for the great leap forward >>preston@titan.rice.edu > > Well, I usually agree with you, Preston, but I think your "Fortran is easy > to understand" bias is showing on this one. ;-) > > -hankd@ecn.purdue.edu