in reply to Class::Interface -- isa() Considered Harmful
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:
- I'd like to be able to check that an object I receive from somewhere can handle the operations I'm about to perform on it
- I'd like that check not to dictate the object's implementation of those operations
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Class::Interface -- isa() Considered Harmful
by chromatic (Archbishop) on Jan 19, 2003 at 18:26 UTC | |
by Aristotle (Chancellor) on Jan 19, 2003 at 19:49 UTC | |
by adrianh (Chancellor) on Jan 19, 2003 at 20:50 UTC | |
by chromatic (Archbishop) on Jan 19, 2003 at 21:37 UTC | |
by Aristotle (Chancellor) on Jan 19, 2003 at 21:57 UTC | |
by adrianh (Chancellor) on Jan 19, 2003 at 21:58 UTC | |
by adrianh (Chancellor) on May 22, 2003 at 14:31 UTC |