🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4096

Re: 0-based/1-based arrays

#4096
From: Ray Dunn
Date: Tue, 15 Mar 1988 22:45
23 lines
1581 bytes
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
Technical Details
Message-ID: <942@micomvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!linus!philabs!micomvax!ray
References: <7161@sol.ARPA> <2740@mmintl.UUCP> <4343@june.cs.washington.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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