On Tuesday 27 February 2007 14:25, Fergal Daly wrote:

> Why not have something like
>
> ---
> package UNIVERSAL::isa;
> our %care_about;
>
> sub import {
>   my $self = shift;
>   @[EMAIL PROTECTED] = ();
> }
>
> sub isa {
>   my ($obj, $class) = @_;
>   # do correct isa stuff
>   warn "my warning" if (exists $care_about{$class}) or (exists
> $care_about{ref $obj});
> }
>
> *UNIVERSAL::isa = sub \&isa;
> ---
> then in Test::MockObject;
>
> use UNIVERSAL::isa __PACKAGE__;
>
> you could even add caller() by default making no different at all.
> Then you only give a warning when people call UNIVERSAL::isa on your
> objects,

Yeah, I was thinking about that last night and this morning.  It's a little 
tricky to allow class methods too, but that part works in UNIVERSAL::isa and 
UNIVERSAL::can right now, so it's doable.

-- c

Reply via email to