You're right -- any call to a method of a MyRxC::quant object will be dispatched to MyRxA::quant.
Since MyRxA::quant does not define the 'visual' method, its @ISA tree will recursively be searched. This is simply Rx::quant, from what I understand. If Rx::quant defines the 'visual' method, then the Rx::quant one is called instead. Otherwise, Rx::quant's @ISA is checked, depth first, for a 'visual' method.
If no 'visual' method is found in MyRxA::quant, then MyRxB::quant (the 2nd entry in @MyRxC::quant::ISA) is checked for 'visual'. Thus, the MyRxB::quant::visual() method will be called.
Now, if Rx::quant defines a 'visual' method (you didn't actually SAY this, but I have a sneaking suspicion that this is why you made your post), you will have to resolve the issue this way:
Explicitly qualifying the package name in the method call will override the usual method lookup. The $this->SUPER::foo() syntax is actually a special case that automagically handles @ISA-ness.package MyRxC::quant; use base 'MyRxA::quant'; use base 'MyRxB::quant'; sub raw { my $this = shift; $this->MyRxA::quant::raw(@_); } sub visual { my $this = shift; $this->MyRxB::quant::visual(@_); }
Note that, if you are ONLY delegating and not adding any of your own code, *and* you KNOW for a fact that MyRxA and MyRxB respectively define 'raw' and 'visual' themselves (i.e. instead of inheriting them), a slightly faster technique may be used:
This would effectively import the 'raw' and 'visual' methods from the corresponding packages into MyRxC, bypassing the extra call induced with the "$this->MyRxA::quant::raw()" code. The tradeoff is that the former technique plays fine with inheritance, while this latter technique only works if MyRxA and MyRxB directly contain the 'raw' and 'visual' subs in their respective namespaces.package MyRxC; *raw = \&MyRxA::quant::raw; *visual = \&MyRxB::quant::visual;
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc
In reply to Re: Multiple Inheritence, Munging @ISA
by Stevie-O
in thread Multiple Inheritence, Munging @ISA
by japhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |