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

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

Thread Previous | Thread Next
David Cantrell
September 27, 2016 11:23
Re: I'd like to get rid of "use UNIVERSAL;"
Message ID:
On Mon, Sep 26, 2016 at 10:32:11PM +0200, ?var Arnfj?r? Bjarmason wrote:

> 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:
> 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.

You'll also break this:

  if(UNIVERSAL::isa($foo, 'Some::Class')) { ...

which is a lot more convenient than checking to see if $foo is blessed,
and if it is calling $foo->isa().

That said, it's not a particularly common idiom and I'm happy to change
it in my code.

David Cantrell | Cake Smuggler Extraordinaire

  "Cynical" is a word used by the naive to describe the experienced.
      George Hills, in uknot

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