Contiguous Arrays

Henry Spencer henry at utzoo.uucp
Sat Feb 25 03:11:02 AEST 1989


In article <1146 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
>... what is really 
>wanted here is the Fortran EQUIVALENCE statement to guarantee that the 
>right thing is done...
>
>Why do language gurus work so hard to keep us from doing the obvious?

Perhaps because, if one's brain has not been warped by too much Fortran,
the obvious solution is different:

	#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...
-- 
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



More information about the Comp.lang.c mailing list