On Thu, 26 Feb 2009, Martin D Kealey wrote:
> On Wed, 25 Feb 2009, Timothy S. Nelson wrote:
> > I'm in favour of retaining the $[ functionality, but lets give it some
> > name like $*INDEX_BEGINNING or something like that, so that it's quite
> > long for people to type :).
> Surely the interpretation of the index should be up to each array-type?
>  role OffsetArray[::ElementType = Object;; int $MinIndex = 1]
>  { [...] }

On Wed, 26 Feb 2009, Larry Wall wrote:
> Oops, too late, by about 23 months.  Please see S09.

Aah yes! The hash-like syntax is much nicer!

S09 (http://perlcabal.org/syn/S09.html#User-defined_array_indexing) saith:
> User-defined array indexing
> Any array may also be given a second set of user-defined indices, which need
> not be zero-based, monotonic, or even integers. Whereas standard array
> indices always start at zero, user-defined indices may start at any finite
> value of any enumerable type. Standard indices are always contiguous, but
> user-defined indices need only be distinct and in an enumerable sequence.

But if the indexes are floating point values, do they have error margins?
*Should* they have error margins?

    my @labels{ atan(1)*2, exp(1), (1+sqrt(5))/2 } = < pi e golden-mean >;

> To define a set of user-defined indices, specify an explicit or enumerable
> list of the indices of each dimension (or the name of an enumerable type) in
> a set of curly braces immediately after the array name:
>     my @dwarves{ 1..7 };
>     my @seasons{ <Spring Summer Autumn Winter> };
>     my enum Months
>         «:Jan(1) Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec»;
>     my @calendar{ Months; 1..31; 9..12,14..17 };    # Business hours only

Hmmm, that reminds me, I was going to ask about enum types that have
implicit modulus:

    my enum Season «Spring Summer Autumn Winter»;
    my Season $s = Winter;
    assert($s == Spring);


Reply via email to