On Jul 17, 8:27 am, James Edward Gray II <ja... / grayproductions.net>
wrote:
> On Jul 17, 2007, at 7:58 AM, Adrian Howard wrote:
>
>
>
> > On 16 Jul 2007, at 19:22, Lloyd Linklater wrote:
>
> >> Tim Pease wrote:
> >>> Actually, if Ruby had been implemented in Fortran or Pascal, then
> >>> most
> >>> certainly arrays would have begun indexing with 1 instead of 0.
>
> >> Ok, I know that this is not a Ruby point, but I feel compelled to
> >> respond.  The basic array in Pascal is zero based.
> > [snip]
>
> > Fortran doesn't care much either. There's a convention for starting
> > at 1, but the language allows you to specify an arbitrary index
> > range for your arrays.
>
> Perl copied that misfeature, though it defaults to zero, in the hopes
> of attracting Fortran programmers.  What they learned was that it
> breaks way too much.  I'm pretty sure it's being removed in Perl 6.
>
> James Edward Gray II

I spent plenty of time trying to explain to people the difference
between using an array in scalar context (to get the number of
elements) and using the "end of array" sigil (to get the last index).
I don't recall seeing people check $#array against -1 to see if the
array was empty, but I remember plenty of iterating over 0 .. @array -
1.

Of course, never did I (seriously) tell people to use $[ .. $#array.
That would work no matter what, but I preferred to think of it as a
test case.  If some module I'm using changed array indexing, let me
know.  I'll never use it again.

--
-yossef

--
-yossef