On Thu, Dec 05, 2002 at 02:45:39AM -0800, Michael G Schwern wrote:
> Explain how having indexes (arrays, substr, etc...) in Perl 6 start at 0
> will benefit most users.  Do not invoke legacy. [1]

Answer 1: Ignoring legacy, it won't.

Answer 2: Because C uses 0-based indexes, Parrot is written in C, and
it would be just painful to switch back and forth when working on
different layers of the system.  (Not a legacy argument, unless you
want to argue that Parrot is a legacy system.)

Answer 3: In a lower-level language than Perl, an array is usually a
block of memory divided into array elements.  The index is the offset
from the start of the array.  In languages like C which allow pointer
arithmetic, it makes sense for the array index to be the element offset,
to allow a[i] to be equal to *(a + i).  Higher level languages should
follow this convention, for consistency.  (Again, not a legacy argument,
since it offers a first-principles rationale for 0-based arrays in
certain contexts.)

                        - Damien

Reply via email to