Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Contiguous Arrays Message-ID: <1989Feb24.171102.10397@utzoo.uucp> Organization: U of Toronto Zoology References: <2508@ssc-vax.UUCP> <8943@alice.UUCP> <1828@valhalla.ee.rochester.edu> <1831@valhalla.ee.rochester.edu> <1146@l.cc.purdue.edu> Date: Fri, 24 Feb 89 17:11:02 GMT In article <1146@l.cc.purdue.edu> cik@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@zoo.toronto.edu