Why are you exporting your import() method?
Why are you even defining an import() method when the one you're inheriting from Exporter should work fine and yours does not? I.e. remove the import() method and fix the obvious syntax errors and you can use your inheir_merge() method from the use()ing package.
Why are you creating an an object of the caller's class to to call SUPER on when you can call caller()->SUPER::inheir_merge() directly?
And finally, what is all this supposed to do that you can't solve with straightforward (mutiple or single) inheritance?
update: ah, I see a bit more. You'll probably just want to export properies. Since all of your properties seem to be class -based (i.e. no object-specific properties) you can for instance declare them as methods:
Flies: Earthbound = 0; Machine: Metallic = 1; Warm-blooded: Blood = "warm"; Kryptonian: Weakness = "Kryptonite";
package Base; # define default values sub earthbound { 0 } sub metallic { 0 } sub blood { "cold" } sub weakness { undef } # update 2: sub validate { my ($class) = @_; return ($class->blood eq 'warm' or ! $class->metallic); } # define 'mixins' - don't subclass these, # they'll export their properties when you use them package Flies; use base Exporter; our @EXPORT = qw(earthbound); sub earthbound { 1 } package Robot; use base Exporter; our @EXPORT = qw(metallic); sub metallic { 1 } # etc... package Superman; use base Base; use Flies; use Robot; # superman's very metallic.
In reply to Re^3: Dealing with design -- inheritance + exporting gone bad :(..
by Joost
in thread Dealing with design -- inheritance + exporting gone bad :(..
by yaneurabeya
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |