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

Re: disabling smartmatch and when()?

Thread Previous | Thread Next
From:
Tomasz Konojacki
Date:
June 20, 2022 15:55
Subject:
Re: disabling smartmatch and when()?
Message ID:
20220620175449.53F6.5C4F47F8@xenu.pl
On Mon, 20 Jun 2022 15:43:44 +0100
Dave Mitchell <davem@iabyn.com> wrote:

> It's gone through a 9 year deprecation cycle, with a mandatory
> experimental warning that you have to explicitly disable.

So signatures were deprecated too? "Experimental" doesn't mean
deprecated. If we want smartmatch to be deprecated, then we should
deprecate it. We should have done that a long time ago, instead of
pretending that signatures/try/isa/whatever have the same status as
smartmatch.

Smartmatch was made "experimental" retroactively and for a large portion
of our users the warnings started appearing as late as 10 years after it
was introduced!

RHEL6: released in 2010, supported until 2020: perl 5.10 (no warnings)
RHEL7: released in 2014, supported until 2024: perl 5.16 (no warnings)
RHEL8: released in 2019, supported until 2029: perl 5.26 (warns)

Not to mention that the "experimental" warning doesn't even attempt to
inform the user what it means:

> perl -E '$z ~~ $b'
Smartmatch is experimental at -e line 1.

Our documentation isn't much better. The meaning of "experimental" is
hidden deep in perlpolicy. There is no *loud and clear* warning in e.g.
the smartmatch section of perlop.

I can't count the times I had to explain to people outside of the p5p
bubble that "experimental" in the case of smartmatch actually means
"deprecated" and they shouldn't use it.

The result of the above is that half of CPAN relies on smartmatch:

https://grep.cpanauthors.org/search?q=%7E%7E+OR+%22given+%28%22+OR+%22given%28%22

And that is just CPAN, there's certainly a lot of it in darkpan code too.

The worst part is that we can't just say "use <X> instead" because there
is no direct replacement for smartmatch and given/when! For each of the
affected modules you have to analyse the code and figure out which one
of the bajillion smartmatch comparison modes was being triggered and
then you have to replace it with something verbose and ugly (e.g.
List::Util::any or if/else-chain), which BTW, is not a good look for
Perl at all.

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