[TUHS] Array index history

shawn wilson ag4ve.us at gmail.com
Fri Jun 9 00:56:18 AEST 2017


On Jun 8, 2017 7:29 AM, "Christian Neukirchen" <chneukirchen at gmail.com>
wrote:

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.


I never thought of it like that wrt awk. However, I always thought of $0 as
"self" in higher level OO languages.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20170608/22a874e0/attachment.html>


More information about the TUHS mailing list