Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!killer!chasm From: chasm@killer.DALLAS.TX.US (Charles Marslett) Newsgroups: comp.lang.c Subject: Re: Contiguous Arrays Summary: Maybe this is even more efficient! Message-ID: <7310@killer.DALLAS.TX.US> Date: 25 Feb 89 05:12:32 GMT References: <2508@ssc-vax.UUCP> <8943@alice.UUCP> <1828@valhalla.ee.rochester.edu> <1989Feb24.171102.10397@utzoo.uucp> Organization: The Unix(R) Connection, Dallas, Texas Lines: 31 In response to the discussion on using pointers to non-memory locations (or non-pointers as pointers, or . . .), In article <1989Feb24.171102.10397@utzoo.uucp>, henry@utzoo.uucp (Henry Spencer) writes: > #define x(n) (space[(n)-101]) > > This involves one annoyance, the change from x[n] to x(n). (But then, > a Fortran enthusiast shouldn't mind that! :-)) But it cures the problem > completely AND PORTABLY. Furthermore, it shouldn't hurt the efficiency > of the code, because on machines where the original trickery was possible, > any decent compiler should implement the portable code that way, by folding > constants in the address calculation. Doing that is one #@#%$%@# of a > lot easier than implementing EQUIVALENCE... And I might add that on machines where direct memory addressing is faster than register indirect addressing (Crays or Cybers maybe?, do any exist, really?), this would be faster than referencing the array through the pointer in the original statement. > -- > The Earth is our mother; | Henry Spencer at U of Toronto Zoology > our nine months are up. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu Charles Marslett [Future enquirng mind . . .] =========================================================================== Charles Marslett STB Systems, Inc. <== Apply all standard disclaimers Wordmark Systems <== No disclaimers required -- that's just me chasm@killer.dallas.tx.us