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

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.

Replies are listed 'Best First'.
Re^8: Perl::Improved Volume 0, Number 0
by hardburn (Abbot) on Aug 30, 2004 at 19:25 UTC

    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.

Re^8: Perl::Improved Volume 0, Number 0
by Roy Johnson (Monsignor) on Aug 30, 2004 at 19:32 UTC
    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.