I'd be interested to know more about your project and why you're considering going down that route. (See: When to use prototype inheritence?). I'm also interested in your experiences after the project.

There's also Class::SelfMethods by the same guy who wrote Class::Prototyped (Toby Everret). It's worth checking out as it had input from Damian Conway and Sean Burke. (Gleaned from the docs).

Unfortunately, I haven't got much practical experience with the modules so can't give you much advice. I'm considering emailing these authors to find out how the modules are being used and what the experience have been. I'll report back if I do.

I have my own, minimal version which is still being designed and debugged and may be ditched for a module implementation
The important bits follow, just 'new' and an AUTOLOAD accessor.

sub AUTOLOAD { # attrs my ($self) = @_; (my $attr = $AUTOLOAD) =~ s/^.*:://; return if $attr eq 'DESTROY'; return $self->{$attr} if(exists $self->{$attr}); return $self->{prototype}->$attr if(exists $self->{prototype}); } =item new Create a new Slot with prototyping. # class method my $proto = SD::Slot->new({ min_val => 1, max_val => 10 }); # $slot is blessed as an SD::Slot and has prototype = $proto my $slot = $proto->new({ min_val => 0 }); # $slot2 isa SD::Slot::Multi but still has prototype = $proto my $slot2 = SD::Slot::Multi->new({ prototype => $proto }); The parameter hashref is blessed into the appropriate class and returned. =cut sub new { my ($class, $proto, $self); # @_ processed conditionally if($class = ref $_[0]) { $proto = shift; # we have a prototype object } else { $class = shift; } $self = shift || {}; if(!exists $self->{prototype} && $proto) { $self->{prototype} = $proto; } bless $self => $class; } # example use (config) my %prototypes; $prototypes{int} = SD::Slot->new({ widget => 'textfield', constraints => [ \&SD::Constraints::integer_rx, \&SD::Constraints::min_val, \&SD::Constraints::max_val, ], }); $prototypes{int1_10} = $prototypes{int}->new({ prototype => $prototypes{int}, skip_warn => 1, min_val => 1, max_val => 10, }); my %slots; $slots{intelligence} = $prototypes{int1_10}->new({ name => 'intelligence', mandatory => 1, constraints => [ # add extra constraint @{ $prototypes{int}->constraints }, sub { $_[1] % 2 or die E->new( "Not an odd number '$_[1]'") }, ], });

Brad


In reply to Re: Class::Classless vs. Class::Prototyped by bsb
in thread Class::Classless vs. Class::Prototyped by John M. Dlugosz

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.