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

Re: smartmatch and v5.36.0

Thread Previous
H.Merijn Brand
June 21, 2021 16:38
Re: smartmatch and v5.36.0
Message ID:
On Sun, 20 Jun 2021 08:34:15 -0400, "Ricardo Signes"
<> 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   Perl Monger
using perl5.00307 .. 5.33        porting perl5 on HP-UX, AIX, and Linux

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About