Living with smart match breakage
dakkar at thenautilus.net
Thu Jun 13 22:44:49 BST 2013
On 2013-06-13 gvim <gvimrc at gmail.com> wrote:
> I hear Perl 5.18 issues warnings when the smart match operator is
Yes, and also when C<given> / C<when> are used.
> and some convoluted boilerplate is necessary to work around
That boilerplate is spelled:
no warnings 'experimental::smartmatch';
or, if you want your code to work unmodified under 5.16 and 5.18 (and
probably all other versions):
use experimental 'smartmatch';
(see https://metacpan.org/release/experimental )
> Since my use of given/when and smart match is quite simplistic
> I'm wondering if the breakage is relevant to the code I write.
Probably not, but my definition of "simplistic" may not be the same as
> A quick search hasn't produced any definitive list of these edge
Let's put it like this: if you are not daunted by the documentation of
the C<~~> operator (see L<perlop/Smartmatch Operator>, 23 cases), and
by the additional cases when it's used inside C<when> (see
L<perlsyn/Experimental Details on given and when>, 10 more cases), you
are much smarter and brave than I am.
> My approach is to keep it simple and defer upgrading beyond 5.16
> until it's fixed.
My approach is to keep using it in the 2-3 cases we already do
(essentially, dispatch based on exception objects inside a
L<Try::Tiny> C<catch> coderef), adding C<use experimental
'smartmatch'> where appropriate.
Dakkar - <Mobilis in mobile>
GPG public key fingerprint = A071 E618 DD2C 5901 9574
6FE2 40EA 9883 7519 3F88
key id = 0x75193F88
It is easy to find fault, if one has that disposition. There was once
a man who, not being able to find any other fault with his coal,
complained that there were too many prehistoric toads in it.
-- Mark Twain, "Pudd'nhead Wilson's Calendar"
More information about the london.pm