|more useful options|
Interfaces in Perl?by gregorovius (Friar)
|on Dec 01, 2000 at 04:02 UTC||Need Help??|
gregorovius has asked for the
wisdom of the Perl Monks concerning the following question:
Dear fellow Monks,
I want to make sure that a number of classes in my program ALWAYS implement a number of methods, much like abstract classes in C++ allow. This has previously been discussed (by some very wise monks) here.
The solution they propose is basically dying in all your perl "abstract class" methods, so you can tell if derived classes are not implementing them.
The problem I see with this approach is that you don't get to know if all abstract methods are overridden in the derived classes until you call them, which happens at runtime! (Please correct me if I'm wrong, but this practice could be dangerous, unless you are sure your testing will always call all the inherited "abstract" methods in all your concrete classes).
My question is: Is there a way to verify that a number of methods are implemented in a package, at compile time?
(note the generality of the question, as I don't really care about having the @ISA relationship)