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

Re: smartmatch and v5.36.0

Thread Previous
From:
H.Merijn Brand
Date:
June 21, 2021 16:38
Subject:
Re: smartmatch and v5.36.0
Message ID:
20210621183750.64c8f384@pc09
On Sun, 20 Jun 2021 08:34:15 -0400, "Ricardo Signes"
<perl.p5p@rjbs.manxome.org> wrote:

> On Sun, Jun 20, 2021, at 7:47 AM, Paul "LeoNerd" Evans wrote:
> > I think we all want shot of that thing, and I expect I won't be the
> > first to throw a party when it goes. But I'm not sure we want to
> > remove it until we have a better replacement, do we?  
> 
> I do.
> 
> I am absolutely not telling people, "We'd like a better matching
> feature, but until we have one, I encourage you to make use of
> given/when."  I say, "Write the code without using given/when and
> maybe someday upgrade it to the new thing."
> 
> This isn't about removing smartmatch from the language.  It's about
> not turning it on when somebody says "use v5.36".

I still don't see the scope clearly.

As it currently stands, I have a script that uses

foreach my $foo (@list_of_foo) {
    given ($foo) {
	when ("foo") {

with 52 when entries spanning 208 lines. The version of this scripts
that used if/else was IIRC about three times as long, unmaintainable
and unreadable.

All the when's are fixed string or regex (another much smaller script
uses numeric constants and undef too).

So no, I *do* want the edge cases of switch gone and all problems that
switch had removed, but until we have something better, I want switch
as it is for the simple cases that cause no problems.
-- 
H.Merijn Brand  https://tux.nl   Perl Monger   http://amsterdam.pm.org/
using perl5.00307 .. 5.33        porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
                           

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