[TUHS] Array index history
arnold at skeeve.com
arnold at skeeve.com
Wed Jun 7 23:20:43 AEST 2017
shawn wilson <ag4ve.us at gmail.com> wrote:
> I learned the other day that array indexes in some languages start at 1
> instead of 0. This seems to be an old trend that changed around the 70s?
> Who started this? Why was the change made?
>
> It seems to have come about around the same time as C, but interestingly
> enough Lua is kinda in between (you can start an array at 0 or 1).
> Smalltalk can probably have a 0 base index just by it's nature, but I
> wonder whether that would work in a 40 year old interpreter.
Basically, until C came along, the standard practice was for indices
to start at 1. Certainly Fortran and Pascal did it that way. I suspect
that all the Algol family languages did too, but I only did a little
Algol W programming in colledge and that was long ago. I think Cobol also.
Pascal (IIRC) allowed you to specify upper and lower bounds, something
like
foo : array[5..10] of integer;
with runtime bounds checking on array accesses. (I could be wrong ---
it's been a LLLLOOONNNGGG time.)
HTH,
Arnold
More information about the TUHS
mailing list