XP is just a number | |
PerlMonks |
Re: checking a method is not subclassedby water (Deacon) |
on Feb 02, 2006 at 17:04 UTC ( [id://527377]=note: print w/replies, xml ) | Need Help?? |
I'm missing something here, or I wasn't clear. Here's some code:
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. 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 Section
Seekers of Perl Wisdom
|
|