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

Re: Elevator pitch, deprecating $a/$b sort globals by using sub{}

Thread Previous
From:
Dan Book
Date:
July 4, 2021 17:11
Subject:
Re: Elevator pitch, deprecating $a/$b sort globals by using sub{}
Message ID:
CABMkAVWjUxov-THjQRcPvzo4f_Ry72rbbBgc5ObDVquwQTrA5Q@mail.gmail.com
On Sun, Jul 4, 2021 at 1:02 PM Nicholas Clark <nick@ccl4.org> wrote:

>
> > Yes, it is longer, but less of a wart. It lessens the cognitive load,
> avoids
> > the $a/b global variables and makes the language more consistent.
>
> The first thing that thought was that this makes sort special, compared
> with the other builtins that take blocks (map, grep)
>
> But those take one implicit argument, for which $_ works just fine.
>

FWIW, I think being able to specify a lexical to use instead of $_ for map
and grep blocks would also be really cool and an alternative to the failed
"lexical $_" experiment for avoiding the global state (e.g. you could call
functions that mess with $_ inside the map or grep without breaking your
code). So perhaps there is a way to solve these problems with
similar syntax.

-Dan

Thread Previous


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