Skip Menu |

This queue is for tickets about the Net-EPP CPAN distribution.

Maintainer(s)' notes

Please don't use rt.cpan.org to submit bug reports! Please email any bug reports to epp@centralnic.com instead. Thanks.

Report information
The Basics
Id: 68776
Status: rejected
Priority: 0/
Queue: Net-EPP

People
Owner: Nobody in particular
Requestors: CARNIL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: using UNIVERSAL::isa as function discouraged
Date: Sun, 12 Jun 2011 13:54:45 +0200
To: bug-net-EPP [...] rt.cpan.org
From: Salvatore Bonaccorso <carnil [...] cpan.org>
Hi This is related to [1]. Reading trough the manpage of UNIVERSAL there was a pointer that indeed importing 'isa' function is deprecated. However the manpage points too to: # but never do this! $is_io = UNIVERSAL::isa($fd, "IO::Handle"); $sub = UNIVERSAL::can($obj, "print"); and instead use the method form for isa: EXPORTS None by default. You may request the import of three functions ("isa", "can", and "VERSION"), but this feature is deprecated and will be removed. Please don't do this in new code. For example, previous versions of this documentation suggested using "isa" as a function to determine the type of a reference: use UNIVERSAL 'isa'; $yes = isa $h, "HASH"; $yes = isa "Foo", "Bar"; The problem is that this code will never call an overridden "isa" method in any class. Instead, use "reftype" from Scalar::Util for the first case: use Scalar::Util 'reftype'; $yes = reftype( $h ) eq "HASH"; and the method form of "isa" for the second: $yes = Foo->isa("Bar"); [1] https://rt.cpan.org/Public/Bug/Display.html?id=67327 I attach a patch to substitute the direct invokation of UNIVERSAL::isa with the method form. Does this looks correct? If you agree, could you apply this to the next upstream version? Bests Salvatore

Message body is not shown because sender requested not to inline it.

Download signature.asc
application/pgp-signature 836b

Message body not shown because it is not plain text.

Please don't use RT to submit bug reports. Email epp@centralnic.com instead. On Sun Jun 12 07:54:59 2011, CARNIL wrote: Show quoted text
> Hi > > This is related to [1]. Reading trough the manpage of UNIVERSAL there > was a pointer that indeed importing 'isa' function is deprecated. > However the manpage points too to: > > # but never do this! > $is_io = UNIVERSAL::isa($fd, "IO::Handle"); > $sub = UNIVERSAL::can($obj, "print"); > > and instead use the method form for isa: > > EXPORTS > None by default. > > You may request the import of three functions ("isa", "can", and > "VERSION"), but this feature is deprecated and will be removed. > Please don't do this in new code. > > For example, previous versions of this documentation suggested > using "isa" as a function to determine the type of a reference: > > use UNIVERSAL 'isa'; > > $yes = isa $h, "HASH"; > $yes = isa "Foo", "Bar"; > > The problem is that this code will never call an overridden "isa" > method in any class. Instead, use "reftype" from Scalar::Util for > the first case: > > use Scalar::Util 'reftype'; > > $yes = reftype( $h ) eq "HASH"; > > and the method form of "isa" for the second: > > $yes = Foo->isa("Bar"); > > [1] https://rt.cpan.org/Public/Bug/Display.html?id=67327 > > I attach a patch to substitute the direct invokation of > UNIVERSAL::isa with the method form. Does this looks correct? If you > agree, could you apply this to the next upstream version? > > Bests > Salvatore