> =head1 TITLE
>
> Open-ended slices
>
<...>
>
>     @thingy = function()
>     for (@thingy[3..$#thingy]) { ... }
>
> Horrible, isn't it? People want something better.
>
> I thought about it last year or so, and produced a couple of patches. It
> seemed then that the right syntax was not, for instance:
>
>     (function())[3...-1]
>
> because sometimes you want C<$x..$y> to return the empty list, but
> actually:
>
>     (function())[3...]
>
> (Or C<[3..]>. It doesn't matter.)
>
The same syntax is proposed in RFC 205 to allow getting a whole slice of an
array. It also appeared in RFC 24 which suggested allowing (0..) anywhere
that C<..> is used. RFC 24 was withdrawn after it became clear that there
were too many cases where this behaviour was bizarre. By restricting this
behaviour to within an index, I think that we avoid the problem.

Can we extend RFC 282 so that it allows the right operand of C<..> to be
omitted in any index, since the upper-bound can be implied? Or does it
already propose this? (...in which case please give an example of an
open-ended slice on an array rather than directly on a function returning a
list.)


Reply via email to