Path: utzoo!mnetor!uunet!husc6!cca!g-rh From: g-rh@cca.CCA.COM (Richard Harter) Newsgroups: comp.lang.misc Subject: Re: The Joy of Zero-based Arrays Message-ID: <25349@cca.CCA.COM> Date: 6 Mar 88 19:30:09 GMT References: <1012@PT.CS.CMU.EDU> <17419@think.UUCP> <213@sdti.UUCP> Reply-To: g-rh@CCA.CCA.COM.UUCP (Richard Harter) Organization: Computer Corp. of America, Cambridge, MA Lines: 33 Most of the fuss and confusion comes about because there are three different kinds of 'numbers' involved: cardinals, ordinals, and displacement measures. A cardinal number is the measure of the size, e.g. this array has five elements. An ordinal number is the count sequence, e.g. this is the 1st element, ... this is the 5'th element. A displacement measure is the distance between an element and the base, e.g. this element is displaced four elements from the base. Ordinals match cardinals, e.g. if a sequence has five elements, the last ordinal corresponds to the cardinal number of the sequence. There are fundamental reasons for not mucking with the definition of ordinal, which I won't go into. Displacement measures are more useful than ordinals in programming. The fundamental reason is that names in programming specify addresses, i.e a[i] is the item located at address 'a[i]'. Regardless of the language array basing index, 'i' is used to determine a displacement from the array address. The fencepost problem is intrinsic -- in a sequence containing 'n' items the displacement between the first and the last element in the sequence is 'n-1'. This fact is not altered by the array basing scheme used. -- In the fields of Hell where the grass grows high Are the graves of dreams allowed to die. Richard Harter, SMDS Inc.