Ben Bacarisse writes: > BartC writes: > >> You need to take your C hat off, I think. > > It's a computing hat. Indexes are best seen as offsets (i.e. as a > measured distances from some origin or base). It's a model that grew > out of machine addressing and assembler address modes many, many > decades ago -- long before C. C, being a low-level language, > obviously borrowed it, but pretty much all the well-thought out > high-level languages have seen the value in it too, though I'd be > interested in hearing about counter examples.
Julia, at version 0.5 of the language, is a major counter-example: 1-based, closed ranges. I think they have been much influenced by the mathematical practice in linear algebra, possibly through another computing language. I think there's some work going on to allow other starting points, or at least 0. Not sure about half-open ranges. > The main issue -- of using a half open interval for a range -- is > probably less widely agreed upon, though I think it should be. EWD is > correct about this (as about so many things). Agreed. (I even use pen and paper, though I don't always remember what I wrote.) -- https://mail.python.org/mailman/listinfo/python-list