Luke Palmer <[EMAIL PROTECTED]> wrote:
> In Perl 5:
> 
>     my @a = (1,2,3);
>     my @b = @a[0..3];
>     print scalar(@b);   # 4
> 
> But in Perl 6:
> 
>     my @a = (1,2,3,4);
>     my @b = @a[1...];  # elements from 1 onward
>     say [EMAIL PROTECTED];   # should probably be 3, but with Perl 5 
> semantics is Inf
> 
> We have to break one of these.  I think the former is the one to break,
> even though that might cause some unexpected surprises here and there.
> Any ideas?

I was thinking about this today, actually, because my CS textbook was
talking about multidimensional arrays.  If we make an infinite index
mean "slice until you can slice no more", then we can possibly have a
C<term:<*>> which is the same as C<0...>.  That means we can slice
like this:

    @foo[1,3; *; 7]

Which I rather like.  (Although term:<*> might conflict with
prefix:<*>...hmm.  I'm not sure it would in common usage--the only
things I can think of that could follow are a dot, opening or closing
bracket, semicolon or comma, or hyperoperator, none of which are
ambiguous if we stick to the no-whitespace-before-postcircumfix rule.)

By the way, this also shortens the common idiom:

    @[EMAIL PROTECTED]

To simply:

    @foo[3...]

Which strikes me as a win.

-- 
Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

"I used to have a life, but I liked mail-reading so much better."

Reply via email to