In this example, I am cool with a user calling bleep on either 'a' or 'b'. I'm also cool with a user calling baz on either 'a' or 'b'. What I'd like to detect from Foo is that a subclass (NewFoo) overrode a certain method. That is, $b->baz calls NewFoo::Baz, as that overrode Foo::Baz.# untested package Foo; sub bleep {...} sub baz { ... } package NewFoo; use base qw(Foo); sub baz { ... } package main; my $a = Foo->new; my $b= NewFoo->new; $a->bleep; $b->bleep; $a->baz; $b->baz;
I'm looking for a way for Foo to detect and carp that a subclass took away its rights to own the code for method baz.
Probably this isn't "nice" OO -- "thou shalt never subclass me, dammnit" isnt friendly -- but I'm wondering how to do it anyway.
I really like the suggestion about just saying "never subclass baz" in the docs (++ to that post), but need something stronger.
The comments above about checking the ref on self don't seem relevant to me, as here the problem is that Foo::baz never gets involved when someone calls baz on $b... it is too late, the baz is then a NewFoo baz at that point.....?
In reply to Re: checking a method is not subclassed
by water
in thread checking a method is not subclassed
by water
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |