develooper Front page | perl.perl5.porters | Postings from August 2021

Re: idea: everything-slices

Thread Previous | Thread Next
From:
Yuki Kimoto
Date:
August 19, 2021 03:39
Subject:
Re: idea: everything-slices
Message ID:
CAExogxM4d=nWL=P-qO4RFgYpGuzJsCOGBaKHqBy0jhNgG76hLw@mail.gmail.com
2021-6-20 10:54 Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:

> Porters,
>
> I feel confident that this should be an RFC, but our process says "post to
> p5p before writing up an RFC," and "write something less format" sounds
> great.  So:
>
> I would like to propose a new piece of syntax.  It's not my own original
> idea, it's come from a few places and individuals independently, but I'm
> the one who's ready to go to bat for it here.  It is the *everything
> slice*.
>
> An everything slice is a slice that includes every element in an
> aggregate.  We can hash out syntax, but let's start by saying "it's a slice
> where the subscript is replaced by a literal asterisk."
>
> So:
>
> @array[*];  # equivalent to @array[ 0 .. $#array ];
> %array[*];  # equivalent to %array[ 0 .. $#array ];
>
> @hash{*};   # equivalent to @hash{ keys %hash };
> %hash{*};   # equivalent to %hash{ keys %hash };
>
>
>
>
Personally,  I'm interested in everything slice.

I feel that the next two are a natural pair.

    my @nums =  $nums->[1, 2, 3];
    my @nums = $nums->[*];

Are you planning the RFC?

Thread Previous | 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