Contiguous Arrays
Charles Marslett
chasm at killer.DALLAS.TX.US
Sat Feb 25 15:12:32 AEST 1989
In response to the discussion on using pointers to non-memory locations (or
non-pointers as pointers, or . . .),
In article <1989Feb24.171102.10397 at utzoo.uucp>, henry at 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 at 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 at killer.dallas.tx.us
More information about the Comp.lang.c
mailing list