Multiple inheritance is great, and Perl handles it just fine as long as you have a clear understanding of your inheritance heirarchy and some of the potential pitfalls (such as those described in perldoc perltoot). Yet it does not discuss the prohibition of using the fields pragma with multiple inheritance. Indeed, I can find no documentation about this whatsoever...
Here's an illustration:
package Parent1;
use fields 'field1';
package Parent2;
use fields 'field2';
package Child;
use base qw(Parent1 Parent2);
This fails with the error: "Can't multiply inherit fields at..."
This doesn't work even when both parents have the same fields.. even when they are provably the same, because they come from a shared grandparent:
package Grandparent;
use fields qw(field1);
package Parent1;
use base 'Grandparent';
package Parent2;
use base 'Grandparent';
package Child;
use base qw(Parent1 Parent2);
One pitfall to implementing this properly is the invariant that the index of a field in a child object is always the same as the index in its parent. I'm not sure this requirement is truly needed, however... unlike in C++, where an object may be accessed using a pointer typed to a parent, Perl always knows the real type of an object when operating on its reference (indeed the fields pseudohash is essentially a vtable, kept on every single object instance). And particularly in the second example above, the fields inherited from each parent come from both parents, so they can be folded together and there is no conflicting index.
I'm sure there are other issues as well, but I haven't yet found them.
Can anyone with some knowledge of Perl's internals comment on this?