Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: nonzero lower bounds in arryas Message-ID: <1775@umcp-cs.UUCP> Date: Mon, 2-Jun-86 03:21:14 EDT Article-I.D.: umcp-cs.1775 Posted: Mon Jun 2 03:21:14 1986 Date-Received: Tue, 3-Jun-86 23:49:39 EDT References: <1594@ecsvax.UUCP> <853@bentley.UUCP> <1621@ecsvax.UUCP> <900@ttrdc.UUCP> <2157@mit-eddie.MIT.EDU> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 28 In article <2157@mit-eddie.MIT.EDU> barmar@mit-eddie.UUCP (Barry Margolin) writes: >In article <900@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >>By the way, this does raise a question in my mind about how the convention >>of 1, not 0, being the lower bound subscript for an array is gotten around >>efficiently in implementations of Fortran. [levy] >In the case of one-dimensional arrays, of course, it can be handled at >compile time. [barmar] Actually, in all cases it can be handled at compile time, with what is, as I recall, referred to as a virtual origin (did I get the name right, John?). For example, given the declaration var arr : array [1..3, 5..6, -8..7] of char; and the assumption that we are to dispense with subscript checking, find the address of arr[0, 0, 0], then use that as the `origin' of the array, instead of the array name itself. The idea is that the correction factor for each subscript is a constant, and that it is then multiplied by a constant and added to other constants ... which of course gives a constant result. Simply factor out the constants, and then forget the origins! -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu