in reply to a question on namespaces and inheritance

An object can call a method in any namespace by explicitly stating the namespace of that method:
my $obj = ChildClass1->new; $obj->ChildClass2::method(...);
In addition, classes should not "export methods". The only functions that should be exported are non-object-associated.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: a question on namespaces and inheritance
by salva (Canon) on Jun 03, 2005 at 10:10 UTC
    An object can call a method in any namespace by explicitly stating the namespace of that method

    Just because you can it doesn't mean it is a good idea to do so... actually, I found it rather a bad idea to call a method on an object that's not related via an is-a relation to the method package.

    The obvious solution for the OP problem is to move the common methods to the base class or to use a mixin class.

      I would disagree, if the classes are his design. If he knows the class structure, he should be able to do this confidently.

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart