Xref: utzoo comp.lang.modula2:701 comp.lang.misc:1249 Path: utzoo!mnetor!uunet!husc6!linus!philabs!micomvax!ray From: ray@micomvax.UUCP (Ray Dunn) Newsgroups: comp.lang.modula2,comp.lang.misc Subject: Re: 0-based/1-based arrays Message-ID: <942@micomvax.UUCP> Date: 15 Mar 88 22:45:06 GMT References: <7161@sol.ARPA> <2740@mmintl.UUCP> <4343@june.cs.washington.edu> Reply-To: ray@micomvax.UUCP (Ray Dunn) Organization: Philips Electronics Ltd. (TDS - Montreal) St. Laurent P.Q., Canada Lines: 23 In article <4343@june.cs.washington.edu> pattis@june.cs.washington.edu (Richard Pattis) writes: >I too detest 0-based arrays (and think 1-based arrays are better). In trying >to rationalize this choice, I came up the the following argument: When we >process arrays, we often need to know the size of the array and/or the >position of the last element. In 0-based arrays, these quantites are off by >one; in 1-based arrays they are the same. Hence, I think that people will >make fewer errors with 1-based arrays. > The question is, I believe, does the 'structure' fit naturally with the problem you are trying to solve when using the array. Sometimes 0-based is what you want, sometime 1-based is what you want, sometimes n, or -n or etc is what you want! How does the Algol declaration go?? (thinks back about 15 years) array[x:y]?? (I probably have the syntax wrong!) where x and y are positive or negative integers defining the lower and upper bounds of the array's index! Thus i[-20:50] is a 71 element array indexed from -20 through 50. Ray Dunn. {philabs, mnetor, musocs}!micomvax!ray