in reply to Re^5: Perl::Improved Volume 0, Number 0
in thread Perl::Improved Volume 0, Number 0

Better still, have .. do some magic when unary to go right to the end of the array being indexed:

$a[ 5 .. ]; # Equivilent to $a[ 5 .. $#a ]

Though I have no idea how hard that would be to add, or what compatibility issues come up.

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Replies are listed 'Best First'.
Re^7: Perl::Improved Volume 0, Number 0
by Aristotle (Chancellor) on Aug 30, 2004 at 21:08 UTC

    I may be mistaken (I have a hard time following all the developments and keeping the status quo straight), but to my knowledge, that's supposed to work Perl6.

    Makeshifts last the longest.

Re^7: Perl::Improved Volume 0, Number 0
by ambrus (Abbot) on Aug 30, 2004 at 19:20 UTC

    That would be difficult, because 5..$#a is not always used in such a context (subscripting). It is used in other code like @data[sort { $data[$a]<=>$data[$b] } 0..$#data] where it would be difficult to derive the endpoint automatically.

    Btw I think perl6 will have infinite ranges, which is a good idea.

      Well, since the theoretical unary .. is already magical, you could just say that using it outside an array slice is a syntax error, just like it is now.

      Of course, you'll inevitably get newbies who ask why @a = 1 .. ; doesn't work, much how they see while(<FH>) now and expect <FH>; $s = $_ . 'foo'; to work.

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      This construct: 0..$#data oughta be something like @#data  # all the indexes of @data, regardless of where your indexes start

      Caution: Contents may have been coded under pressure.