I understand that Perl’s OO model is rather primitive; it is, in most respects, essentially a namespace hack.
Nevertheless, I wonder if it is possible to create something like an “interface?” My goal is to have a base class from which others are extended whose principal purpose is to make mandatory the implementation of certain methods (by name is fine, no signature necessary) by those subclasses. I don’t really care if it’s a “purely virtual” class (like an “interface” in Java) or a concrete class with actual implementational stubs for those methods in the superclass, but what I want is to make it deterministically necessary that the subclass implement certain methods of the superclass.
Is this possible? If so, how?
I think the whole idea of mandating implementation/overloading of base class’s functions/subs is foreign to Perl. At which point would you envision the enforcement mechanism working?
If you’re OK with doing this at runtime, you can die if your base class’s implementation gets called.
EDIT: Actually, yes, Class::Contract seems to be the way to go.