in reply to Re: "polymorphism" hack: nuts or wise?
in thread "polymorphism" hack: nuts or wise?

Can you give a good example of how that works here? The original poster didn't say these objects were related via inheritance. A Tree probably isn't a subclass of Trees. The latter sounds like a collection of the former. The only inheritance being talked about in that node is the "listable" abstract base class. Trying to shoehorn inheritance into this model could be a bad thing, but maybe you're seeing something I'm not.

Cheers,
Ovid

New address of my CGI Course.

  • Comment on Re^2: "polymorphism" hack: nuts or wise?

Replies are listed 'Best First'.
Re^3: "polymorphism" hack: nuts or wise?
by perrin (Chancellor) on Aug 26, 2005 at 18:16 UTC
    In this case, inheritance would just be used to mark classes as implementing a certain interface. There is no "implements" equivalent in Perl, so you can fake it by making an empty class with a descriptive name and POD that describes an interface, and then adding it to the @ISA for classes which implement that interface. Then you have a simple way to check, via isa().

      Ah, now I get it. I was thinking that inheritance is bad because what one really cares about is interface, not type. Faking "implements" makes that problem go away. (Another tool for my box. Thanks!)

      Cheers,
      Ovid

      New address of my CGI Course.

Re^3: "polymorphism" hack: nuts or wise?
by exussum0 (Vicar) on Aug 26, 2005 at 18:10 UTC
    Sure. And I'm suggesting inheritance as a different road than using methods to determine type. He doesn't wish for nodes to be inserted into certain containers, no?

    Check out Re: "polymorphism" hack: nuts or wise?,(Update Re^3: "polymorphism" hack: nuts or wise?). Grape limes link a bike?

    ----
    Give me strength for today.. I will not talk it away.. Just for a moment..
    It will burn through the clouds.. and shine down on me.

Re^3: "polymorphism" hack: nuts or wise?
by rvosa (Curate) on Aug 28, 2005 at 11:46 UTC
    Yes, you're right: a node isn't a special case of a tree - and neither is a tree a special case of a trees object. Also, I'm a bit worried about multiple inheritance. I may want to implement use fields; and I can imagine going crazy if I have multiple inheritance.