[TUHS] Array index history
michael at kjorling.se
Wed Jun 7 23:50:04 AEST 2017
On 7 Jun 2017 07:20 -0600, from arnold at skeeve.com:
> 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.
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.
https://www.bell-labs.com/usr/dmr/www/kbman.pdf page 8 (PDF page 10)
> 7. A vector is a primary expression followed by any expression in 
> brackets. The two expressions are evaluated to rvalues, added and
> the result is used as an lvalue. The primary expression can be
> thought of as a pointer to the base of a vector, while the bracketed
> expression can be thought of as the offset in the vector. Since
> E1[E2] is identical to *(E1+E2), and addition is commutative, the
> base of the vector and teh offset in the vector can swap positions.
And https://www.bell-labs.com/usr/dmr/www/bcpl.pdf page 11 (PDF page
> 4.7 Vector Applications
> Semantics: A vector is represented by a pointer to a consecutive
> group of words which are the elements of the vector. The pointer
> points to the zeroth element.
Michael Kjörling • https://michael.kjorling.se • michael at kjorling.se
“People who think they know everything really annoy
those of us who know we don’t.” (Bjarne Stroustrup)
More information about the TUHS