develooper Front page | perl.perl5.porters | Postings from July 2013

[perl #118089] Feature: list slices to the end

Thread Next
From:
Father Chrysostomos via RT
Date:
July 7, 2013 00:36
Subject:
[perl #118089] Feature: list slices to the end
Message ID:
rt-3.6.HEAD-2552-1373157376-415.118089-15-0@perl.org
On Sun Jun 09 06:55:59 2013, perl.p5p@rjbs.manxome.org wrote:
> 
> For the record, I am open to a patch to provide this kind of change,
> and am not
> particular as to which of the suggestions is used, as long as the work
> is
> sound.

Of the two suggestions, I think $# is best.  If list and array slices
could record the length in an interpreter variable localised to the
brackets on the right, $# could be a magical variable accessing that.

That would make all three of these work:

# Omit the first element
@a = (gimme_list())[1..$#];
@a = @b[1..$#];
sub end { $# }
@a = (gimme_list())[1..end];

Do we want that?

As for the [1..] suggestion, would that be a postfix .. operator applied
to the 1?  Or would ..] be a special way to end the subscript?  I.e.,
should [5.., 2] be allowed or not?  And if we can access this number,
why restrict it to ranges?

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=118089

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About