On Tue, Sep 28, 2010 at 11:11 PM, <[email protected]> wrote:
> I have used languages (PL/1 and Pascal come to mind) that allow you to
> declare both upper and lower bounds to each array dimension. But for
> both languages, I have found such arrays more trouble than they are
> worth. A Pascal example I saw created a histogram of something grouped
> by year (declared as "array [1970..1984] of integer", or some such).
User-defined array indexing is included in Perl 6:
my Int @array{1970..1984};
The lower bound of the built-in indexing cannot be changed from 0 and
the built-in indexing is always available via square brackets. The
user-defined indexing is available via curly braces. For example,
both @array[0] and @array{1970} could be used to access the first
value.
And here's the relevant section of the spec:
http://perlcabal.org/syn/S09.html#User-defined_array_indexing
However, it is not yet implemented in Rakudo.
> But since the bounds must be fixed at compile time, you cannot write a
> practical *general* histogram generator this way.
This also appears to be the case with user-defined array indexing in Perl 6.
Nick
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm