Path: utzoo!attcan!uunet!pyrdc!pyrnj!rutgers!noao!arizona!mike From: mike@arizona.edu (Mike Coffin) Newsgroups: comp.lang.fortran Subject: Re: RE: An array by any other name. . . Message-ID: <7066@megaron.arizona.edu> Date: 16 Sep 88 01:57:23 GMT References: <3641@lanl.gov> Organization: U of Arizona CS Dept, Tucson Lines: 25 From article <3641@lanl.gov>, by jlg@lanl.gov (Jim Giles): > x[i] and *(x+i) are semantically equivalent in C. I don't _want_ them to > be. When I ask for an array, I will always use the first syntax. When > I ask for a pointer, I will always use the second. Yes, x[i] and *(x+i) are semantically equivalent. But nothing says that x[i] means the same whether x is an array or a pointer (nor that *(x+i) means the same whether x is an array or a pointer). There is nothing wrong with an implementation that generates range-checking code if x is an array, but doesn't if it is a pointer. There is *nothing* hard about doing this: one bit in the symbol table suffices to differentiate between pointers and arrays. The fact that most compilers don't bother is just tradition. So what you are asking (I guess) is that you would like the syntax --- brackets vs. * and + --- to be a redundant reminder to the reader that x is an array or a pointer. I can't argue with your preference, but the way it's done does have some advantages. Chiefly, I guess, the ability to build data structures that are *not* arrays, but can be treated like arrays in many ways. (Whether these are Good Things is an argument I refuse to get into.) -- Mike Coffin mike@arizona.edu Univ. of Ariz. Dept. of Comp. Sci. {allegra,cmcl2,ihnp4}!arizona!mike Tucson, AZ 85721 (602)621-2858