[Python-ideas] [Python-Dev] Inclusive Range

Masklinn masklinn at masklinn.net
Tue Oct 5 11:08:35 CEST 2010


On 2010-10-05, at 10:54 , Carl M. Johnson wrote:

> Changing range would only make sense if lists were also changed to
> start at 1 instead of 0, and that's never gonna happen. It's a
> massively backwards incompatible change with no real offsetting
> advantage.
> 
> Still, if you were designing a brand new language today, would you
> have arrays/lists start at 0 or 1? (Or compromise and do .5?) I
> personally lean towards 1, since I recall being frequently tripped up
> by the first element in an array being a[0] way back when I first
> learn C++ in the 20th century. But maybe this was because I had been
> messed up by writing BASIC for loops from 1 to n before that? Is there
> anyone with teaching experience here? Is this much of a problem for
> young people learning Python (or any other zero-based indexing
> language) as their first language?
> 
> What do you guys think? Now that simplifying pointer arithmetic isn't
> such an important consideration, is it still better to do zero-based
> indexing?

I will refer to EWD 831[0], which talks about ranges and starting indexes without *once* referring to pointers.

Pointers are in fact entirely irrelevant to the discussion: FORTRAN and ALGOL 60, among many others, used 1-indexed collections. Some languages (ADA, I believe, though I am by no means certain) also allow for arbitrary starting indexes.

[0] http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF


More information about the Python-ideas mailing list