Perl Monk, Perl Meditation | |
PerlMonks |
Re: Class::Interface -- isa() Considered Harmfulby adrianh (Chancellor) |
on Jan 19, 2003 at 17:33 UTC ( [id://228192]=note: print w/replies, xml ) | Need Help?? |
Since nobody else has mentioned them - there are a couple of similar modules already on CPAN.
Interfaces, Interfaces in Perl? and Re: Interfaces seem to cover similar themes too. I always saw Java interfaces as a response to the naming resolution problems of C++'s implementation of multiple inheritance. Personally, I think they threw out the baby with the bathwater by only allowing multiple-inheritance of interface :-) Compile time warnings are a good thing obviously, but that's a separate issue from interface vs. abstract base classes. I have to admit, I still don't have a handle on how what you want is different from Java-ish interfaces, or inheriting from an abstract class. Can you give an example that shows where abstract classes / interfaces wouldn't be enough? (If it is different from the Java concept I strongly agree with fever that it should be called something else to avoid confusion :-) You said:
Inheriting from an abstract base class seems to meet both of these goals - or am I missing something? There could be an argument for having something like this as a way to retrofit an "abstract" interface onto a pre-existing class. I could see that being useful when you don't control the source. But if you do control the source expressing the interface using an abstract class (maybe using Attribute::Abstract, Class::Virtual or Class::Virtually::Abstract) would seem more straightforward.
In Section
Meditations
|
|