The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

UNIVERSAL::isa - Attempt to recover from people calling UNIVERSAL::isa as a function

SYNOPSIS

    # from the shell
    echo 'export PERL5OPT=-MUNIVERSAL::isa' >> /etc/profile

    # within your program
    use UNIVERSAL::isa;

    # enable warnings for all dodgy uses of UNIVERSAL::isa
    use UNIVERSAL::isa 'verbose';

DESCRIPTION

Whenever you use "isa" in UNIVERSAL as a function, a kitten using Test::MockObject dies. Normally, the kittens would be helpless, but if they use UNIVERSAL::isa (the module whose docs you are reading), the kittens can live long and prosper.

This module replaces UNIVERSAL::isa with a version that makes sure that, when called as a function on objects which override isa, isa will call the appropriate method on those objects

In all other cases, the real UNIVERSAL::isa gets called directly.

WARNINGS

If the lexical warnings pragma is available, this module will emit a warning for each naughty invocation of UNIVERSAL::isa. Silence these warnings by saying:

    no warnings 'UNIVERSAL::isa';

in the lexical scope of the naughty code.

In version 1.00, warnings only appear when naughty code calls UNIVERSAL::isa() as a function on an invocant for which there is an overridden isa(). These are really truly bugs, and you should fix them rather than relying on this module to find them.

To get warnings for all potentially dangerous uses of UNIVERSAL::isa() as a function, not a method (that is, for all uses of the method as a function), pass the verbose flag when using the module. This can generate many extra warnings, but they're more specific as to the actual wrong practice and they usually suggest proper fixes.

SEE ALSO

UNIVERSAL::can for a more mature discussion of the problem at hand.

Test::MockObject for one example of a module that really needs to override isa().

AUTHORS

Autrijus Tang <autrijus@autrijus.org>

chromatic <chromatic@wgz.org>

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT & LICENSE

Same as Perl, (c) 2005 - 2007.