[SciPy-user] Array Bounds

Steven H. Rogers steve at shrogers.com
Sat Mar 10 13:36:21 EST 2007


John Hassler wrote:
> There is no way to make everybody happy, I'm afraid.  Early Fortran was 
> one-based.  A text I used to use (Carnahan, et al, "Applied Numerical 
> Methods," 1969) warns of the difficulty of translating mathematical sums 
> starting with zero to Fortran indices starting with 1.  On the other 
> hand, Press, et al., "Numerical Recipes in C," 1988, 1992, spend an 
> entire page justifying their practice of converting all C arrays to 
> one-based.  (This, by the way, has been roundly criticized by "real" C 
> programmers.)
> 
> Pascal, Fortran 77, and perhaps other 'modern' languages, allow 
> specifying both ends of the range, as in x[2:7] or something.  Some 
> people like this.  I find that it's just one more thing to keep track 
> of.  (By this I mean, if you see x[4] somewhere in a program, you have 
> to look back at the declaration to know what it means.)  I suppose that 
> something like this in Python would also require that one ALWAYS specify 
> both ends of range().
> 

For casual use, many would find it convenient to be able to change from 
0-based to 1-based indexing (APL allows this).  For larger programs 
touched by multiple programmers over time, it's a maintenance issue.

# Steve



More information about the SciPy-User mailing list