[TUHS] Array index history

Johnny Billquist bqt at update.uu.se
Fri Jun 9 08:29:29 AEST 2017

On 2017-06-07 19:01, "Ron Natalie"<ron at ronnatalie.com> wrote:
> The original FORTRAN and BASIC arrays started indexing at one because everybody other than computer scientists start counting at 1.

FORTRAN, yes. BASIC (which dialect might we be talking about?) normally 
actually start with 0. However, BASIC is weird, in that the DIM 
statement is actually specifying the highest usable index, and not the 
size of the array.


DIM X(10)

means you get an array with 11 elements. So, people who wanted to use 
array starting at 1 would still be happy, and if you wanted to start at 
0, that also worked. You might unintentionally have a bit of wasted 
memory, though.

> These languages were for scientists and the beginner, so you wanted to make things compatible with their normal concepts.


> PASCAL on the other hand required you to give the minimum and maximum index for the array.

In a way, PASCAL makes the most sense. You still what range you want, 
and you get that. Anything works, and it's up to you.
That said, PASCAL could get a bit ugly when passing arrays as arguments 
to functions because of this.

> Of course, C’s half-assaed implementation of arrays kind of depends on zero-indexing to work.



Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt at softjar.se             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol

More information about the TUHS mailing list