Hi ,

... sounds like my description wasn't the best in the world.
import is used solely for the (pure abstract) inheritor to define the interface it expects its inheritors to implement.
AUTOLOAD is used solely to catch unimplemented methods, mutators etc. and provide a categorised croak.

In outline, the implementation was along the following lines (I'm afraid I havn't got the actual code to hand at the moment - it's on a memory stick @ work & I'm working from home at the time of writing - doncha just hate it when that happens)...

package AbstractBase; use strict; use warnings; use Carp qw/confess/; use Storable qw/dclone/; my %DEF_INTERFACE = ( methods => [], mutators => [], ); use vars qw/%INTERFACES/; sub import { my ($self, $caller) = (shift, caller); %INTERFACES{$caller} = dclone { (%DEF_INTERFACE), @_ }; } sub AUTOLOAD { my $self = shift; (my $method = $AUTOLOAD) =~ s/(.*::)//; my $interface = $INTERFACES{$1}; croak "Abstract method not instantiated: $method" if grep /^$method$/, @{$interface->{methods}}; croak "Mutator method not instantiated: $method" if grep /^$method$/, @{$interface->{mutators}}; croak "Undefined interface component: $method"; }

At last, a user level that overstates my experience :-))

In reply to Re^2: Inheritable pragma ... or how I learnt perls' compilation order by Bloodnok
in thread Inheritable pragma ... or how I learnt perls' compilation order by Bloodnok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.