The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] Array index history
@ 2017-06-08  2:27 Doug McIlroy
  2017-06-08 12:49 ` William Cheswick
  0 siblings, 1 reply; 52+ messages in thread
From: Doug McIlroy @ 2017-06-08  2:27 UTC (permalink / raw)


>  Who started this? Why was the change made?

Arrays in Fortran and Algol were indexed from 1 by default, but
Algol (IIRC) generalized that to allow first:last declarations. 
NPL used first,last for the SUBSTR operation. But first,last 
begets off-by-one errors. The successor slice begins at last+1.
The formula for the position of 1-indexed a[i,j] is a mess.
First,length is much cleaner: the successor begins at
first+length. I convinced the committee of that, so when
NPL became PL/I, first,length was the convention. Zero-
indexing is also a clean first,length notation. BCPL,
where a[i] was synonymous with rv(a+i), had it. Dennis, who
knew a good thing when he saw it, took it over. Dijkstra,
too, often inveighed against 1-indexing, and opined that
zero was the true computer-science way. 

1-indexing certainly came into programming languages from
the math tradition for matrix notation. Of course in
math series are often indexed from zero, so one may
pick and choose. Off hand I can only think of one CS
context where 1 comes in handy: heapsort.

Doug


^ permalink raw reply	[flat|nested] 52+ messages in thread
* [TUHS] Array index history
@ 2017-06-08  9:16 Richard Tobin
  0 siblings, 0 replies; 52+ messages in thread
From: Richard Tobin @ 2017-06-08  9:16 UTC (permalink / raw)


> Basically, until C came along, the standard practice was for indices
> to start at 1. Certainly Fortran and Pascal did it that way.

Mercury Autocode used 0.

  http://www.homepages.ed.ac.uk/jwp/history/mercury/manual/autocode/4.jpg

-- Richard

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



^ permalink raw reply	[flat|nested] 52+ messages in thread
[parent not found: <mailman.882.1496854900.3779.tuhs@minnie.tuhs.org>]
[parent not found: <mailman.890.1496953026.3779.tuhs@minnie.tuhs.org>]

end of thread, other threads:[~2017-06-10 21:08 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAH_OBiewwwS6kbdWKUO-j3v=Do+Y9AzBn4ZkyVic7LOJN5WX7w@mail.gmail.com>
     [not found] ` <CAH_OBid5q-YeB6UYeOfjW68s3nb3TX_icC5dFMapfo=7_q5DUQ@mail.gmail.com>
     [not found]   ` <CAH_OBideJeNGiiys=VOEYcU1cffSg+6zDOD39HOU74vumQF0kA@mail.gmail.com>
     [not found]     ` <CAH_OBie_+dQXOC2OaZii5K=j1Ljmv-OvAVXvyypoLJ10jaysWA@mail.gmail.com>
     [not found]       ` <CAH_OBidXd1Lpgp8ttM3sWLfXDT0ms5EGAzEjPH9QkY+bXyev2w@mail.gmail.com>
     [not found]         ` <CAH_OBifge2RrwcDvSV46gwLAc0wHVtH++gdMBhXi-x8C0a_2jw@mail.gmail.com>
     [not found]           ` <CAH_OBic3MTy-20C_T2ciT2x+EjNZvXR2PJ0OzB0qRp1gd2OL-g@mail.gmail.com>
2017-06-07 12:56             ` [TUHS] Array index history shawn wilson
2017-06-07 13:16               ` Ron Natalie
2017-06-07 13:20               ` arnold
2017-06-07 13:50                 ` Michael Kjörling
2017-06-07 14:02                   ` arnold
2017-06-08 11:28                     ` Christian Neukirchen
2017-06-08 14:56                       ` shawn wilson
2017-06-07 14:58                   ` Tony Finch
2017-06-07 23:57                     ` Dave Horsfall
2017-06-07 16:31                 ` Lyndon Nerenberg
2017-06-08  0:47                 ` Bakul Shah
2017-06-07 17:59               ` Tim Bradshaw
2017-06-07 18:29               ` Clem Cole
2017-06-07 18:46                 ` Arthur Krewat
2017-06-07 19:03                   ` Ron Natalie
2017-06-07 19:15                     ` Arthur Krewat
2017-06-07 19:49                       ` Ron Natalie
2017-06-08  1:58                       ` ARJANEN Loïc Jean David
2017-06-08 13:49                       ` Random832
2017-06-08 13:55                         ` Arthur Krewat
2017-06-08 18:41                       ` Tim Bradshaw
2017-06-08  2:45                     ` Robert Swierczek
2017-06-08  4:05                       ` Dave Horsfall
2017-06-08  6:19                       ` Peter Jeremy
2017-06-08  7:02                         ` Dave Horsfall
2017-06-08 13:53                         ` Ron Natalie
2017-06-08  2:27 Doug McIlroy
2017-06-08 12:49 ` William Cheswick
2017-06-08 12:56   ` Michael Kjörling
2017-06-08 13:45     ` Dan Cross
2017-06-08 13:57       ` Ron Natalie
2017-06-10 21:08     ` Nemo
2017-06-08 15:04   ` Dave Horsfall
2017-06-08 15:09     ` William Pechter
2017-06-08 16:53     ` Steve Nickolas
2017-06-08 20:17     ` Larry McVoy
2017-06-09  0:03     ` Greg 'groggy' Lehey
2017-06-08  9:16 Richard Tobin
     [not found] <mailman.882.1496854900.3779.tuhs@minnie.tuhs.org>
2017-06-08 18:20 ` David
2017-06-08 18:55   ` Ron Natalie
2017-06-09 21:21   ` Steve Johnson
2017-06-09 21:52     ` Arthur Krewat
2017-06-08 22:29 ` Johnny Billquist
2017-06-08 23:16   ` Ron Natalie
2017-06-08 23:41     ` Steve Nickolas
2017-06-09 15:12       ` Random832
2017-06-09 16:30         ` Ron Natalie
2017-06-09  0:21     ` Johnny Billquist
2017-06-09  0:25     ` Pete Turnbull
2017-06-09  1:19       ` Toby Thain
2017-06-09  2:14         ` Pete Turnbull
     [not found] <mailman.890.1496953026.3779.tuhs@minnie.tuhs.org>
2017-06-08 22:28 ` Johnny Billquist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).