Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • You admit you are on thin ice, so allow me to pull you back before you break through.

    Multiple Inheritance is a fundamental OO concept.

    The only programming language I know that *safely* implements it is Eiffel.

    Most people who get in trouble with MI don't realize the fundamental danger of method name conflicts, and how they must be resolved. That is the issue with the bug you reference (not in Exporter after all, but with Class::Accessor::Fast).

    OOSC2 (Meyer, 1997) highlights two "interesting issues" at the very beginning of the chapter on MI:

    * Feature renaming (feature = method/attribute)
    * Repeated inheritance

    These issues can be learned, and MI can be used properly. And they are not only "interesting," they are essential.

    I agree this far: if you don't understand these issues, stay away from MI or don't cry when you get hurt!

    The sad fact is that most current programming languages (including perl) give you the power without the safety. Think power [name your favorite woodworking tool] without guards. Unfortunately, no language can help a design that shoehorns in inheritance (of any sort) where it doesn't belong.

    To the extent that Roles deals with the feature renaming issue (my understanding is, it does this well), it is a useful safety feature and should be used! As far as OO design is concerned, Roles is implementing a commonly needed and restricted form of inheritance, Structural Inheritance of Partially Deferred Classes (Meyer).

    Roles is not an alternative to the design concept of Multiple Inheritance (good!), but to the generally unsafe (bad!) implementation of MI in common perl practice.

    I have used multiple inheritance (carefully!) in both C++ and Perl with great success. Of course there was the time I found g++ had a bug in its handling of multiple dispatching ... ;-)

    • Roles is not an alternative to the design concept of Multiple Inheritance

      What's the design concept of Multiple Inheritance?

      The problem with OO as it's usually conceived is that classes are used both for their responsibilities -- which tends to make the classes larger -- and for behavioral reuse (frequently via inheritance). When you want to share behavior in a procedural module, we know that it's usually a bad idea to have modules automatically pollute your code with a bunch of functions you didn't ask to import. You should ask for them explicitly (via @IMPORT_OK if using Expo