Perl Monk, Perl Meditation | |
PerlMonks |
Re: Package-specific Attribute Handling and Multiple Inheritenceby Roger (Parson) |
on Sep 03, 2005 at 14:12 UTC ( [id://488920]=note: print w/replies, xml ) | Need Help?? |
Quite a few years ago when I was still programming in C++, I found multiple inheritance of virtual functions a very tricky thing to handle. Say, if class C is derived from class A and class B, and provides an overload for virtual function, say, X, that exists in both A and B, then you have to explicitly say which parent you are going to inherit X from, otherwise it will result in compilation error. I see this particular problem similar to what I described above. Multiple inheritance of the MODIFY_CODE_ATTRIBUTES function. What is not declared explicitly in package Three is the member function MODIFY_CODE_ATTRIBUTES that is inherited from its parent, either A or B. Because Perl could not resolve the multiple inheritance, it simply picks the first package, One, as the parent class and ignores B. When the Perl compiler checks the attributes, it first invokes the MODIFY_CODE_ATTRIBUTES function declared in package Three, which is inherited from package One. And when the function returns a non-empty list, Perl assumes that the attributes could not be handled by the parent package as well as itself, and therefore raise the compilation error. I believe a remedy is to provide a MODIFY_CODE_ATTRIBUTES function in package Three that handles multiple inheritence explicitly.
In Section
Seekers of Perl Wisdom
|
|