develooper Front page | perl.perl5.porters | Postings from September 2016

I'd like to get rid of "use UNIVERSAL;"

Thread Next
From:
Ævar Arnfjörð Bjarmason
Date:
September 26, 2016 20:32
Subject:
I'd like to get rid of "use UNIVERSAL;"
Message ID:
CACBZZX4jxu+QK9kE0FqCEMf8845GkUr1PDeuUdwmX=77UmF+Ug@mail.gmail.com
In 5.12 rjbs deprecated "use UNIVERSAL qw(can isa ...)" with a
warning, in v5.22 Dagfinn made this a fatal error.

I've just pushed a smoke-me branch to remote UNIVERSAL::import from
that package, and make its (no)?import a fatal error via a hack to
gv.c: http://perl5.git.perl.org/perl.git/commitdiff/8804321d

The motivation here is that someone doing "use UNIVERSAL;" in some
module shouldn't make $pkg->can("import") true for any value of $pkg
in your program.

But technically this does break backwards compatibility without a
deprecation cycle. Because "use UNIVERSAL;" isn't an error today, and
some code on the CPAN redundantly uses that.

So what do you think we should do about that? Should we wait until
around 2020 until $pkg->can("import") won't be true at a distance by
going through the full warn/error cycle for this, or just try to push
this to blead and see if it's a big deal? The fix to broken code is
trivial, just remove the "use" line for UNIVERSAL, or if you feel you
must have it import it with a () argument.

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