Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Contiguous Arrays Message-ID: <9698@smoke.BRL.MIL> Date: 23 Feb 89 16:34:11 GMT References: <2508@ssc-vax.UUCP> <8943@alice.UUCP> <1828@valhalla.ee.rochester.edu> <1831@valhalla.ee.rochester.edu> <1146@l.cc.purdue.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 30 In article <1146@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >The desired effect should be obtainable by a struct. ?? >But what is really wanted here is the Fortran EQUIVALENCE statement ... Gag, choke. Ask any competent computer/language architect what he thinks about FORTRAN'S EQUIVALENCE statement. It really constrains implementations in generally undesirable ways. >Another way that this can be done is to use some >assembler code to force the arrays to line up. The idea wasn't to get x[] and space[] to "line up" so much as it was to introduce space[] as a kludge in an attempt to avoid allocating space for the unreferenced part of x[]. This doesn't work because of the impossibility of computing out-of-range addresses for space[] on some (e.g. segmented) architectures. >Why do language gurus work so hard to keep us from doing the obvious? Most Algol-like languages, and even FORTRAN-77, allow the exact range of valid subscripts to be specified for an array. C is rather unusual in maintaining a simple model of array, always starting at [0]. There are tradeoffs here; C's model has much nicer abstract properties, but in exchange if the programmer wants offsets he has to arrange to get them himself. Fortunately that is quite trivial to accomplish, due to the power of the C preprocessor. In fact we discussed how to do that in this newsgroup not very many months ago.