[TUHS] Array index history

Christian Neukirchen chneukirchen at gmail.com
Thu Jun 8 21:28:28 AEST 2017


arnold at skeeve.com writes:

> Michael Kjörling <michael at kjorling.se> wrote:
>
>> On the other hand, before C, both B and BCPL used zero-based indexing.
>> So if we trace C's family tree, there is certainly precedence for
>> zero-based indexing into arrays.
>
> Ah. OK. I never used either language. I get the impression that BCPL
> wasn't used / known much in the US, but I could be wrong. I was exposed
> to BASIC and FORTRAN (and computer programming) circa 1976 and to C
> in 1980.  Anything before then is before my time ... :-)

It may be obvious, but awk(1) uses 1-indexing for arrays and string
offsets, and shell arguments are indexed from 1 too (which may be
reasonable given the special behavior of argv[0], but I think this
resulted in rc(1) being 1-indexed for lists).  pic(1) sensibly uses
1-indexing in the "Nth" notation.

-- 
Christian Neukirchen  <chneukirchen at gmail.com>  http://chneukirchen.org



More information about the TUHS mailing list