Fergal Daly wrote:
> sub isa {
> my ($obj, $class) = @_;
> # do correct isa stuff
> warn "my warning" if (exists $care_about{$class}) or (exists
> $care_about{ref $obj});
Consider what if $obj is a subclass of the class you care about? That
should probably get checked, too, as it too overrides isa(). I believe its
going to have to be...
sub _do_i_care {
my $obj = shift;
for my $class (keys %care_about) {
return 1 if $obj->isa($class);
}
return 0;
}
I'm hand waving over the part where isa() might go into a deep recursion
back into UNIVERSAL::isa().
An alternative is to care about any object or class which overrides isa().
sub _do_i_care {
my $thing = shift;
my $isa = $thing->can("isa");
return 1 if $isa ne \&UNIVERSAL::isa;
}
Again, hand waving over possible deep recursion into UNIVERSAL::can().