Multiple inheritance of %FIELDS

Discussion in 'Perl Misc' started by Mintcake, May 13, 2006.

  1. Mintcake

    Mintcake Guest

    There are 5 small files in this example:

    foo.pl: use p4;
    p1.pm: package p1; use fields qw(a b); 1;
    p2.pm: package p2; use base 'p1'; 1;
    p3.pm: package p3; use base 'p1'; 1;
    p4.pm: package p4; use base qw(p2 p3); 1;

    When I compile foo.pl I get the following error:

    Can't multiply inherit %FIELDS at /home/tony/Projects/bin/p4.pm line 1

    Now I can see that if both p2 and p3 had introduced additional fileds
    then they would occupy the same space and cause potential runtime
    confusion. But, if only one of the packages p2 and p3 introduced
    additional fields or (as in the above example) neither of them did, it
    ought to work.
     
    Mintcake, May 13, 2006
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.