Aristotle Pagaltzis <pagaltzis@gmx.de> wrote:
:* Jerry D. Hedden <jdhedden@cpan.org> [2009-12-23 20:00]:
:> No, isa() and can() should not be called as procedures. They
:> are methods: $item->isa('thing') for example.
:
:Mind that you also have to wrap those in `eval` or guard them
:with a `blessed` check. Would be nice if core shipped functions
:to wrap up the correct behaviour concisely and efficiently…
:related to the Scalar::Util-inspired discussion about having
:a way to make XSUBs into ops.
FWIW I have copies of this scattered around various codebases:
sub _isa {
my($val, $class) = @_;
eval { $val->can('isa') }
? $val->isa($class)
: UNIVERSAL::isa($val, $class);
}
I'd love not to need it any more, but I don't see how to get there from here.
Hugo
Thread Previous
|
Thread Next