Honorable Monks,

Can anyone point me to a little open-source project where the Class::Std object system was used. I'd like to get some inspiration on how code using this looks like in real life.

Currently I am not using Class::Std in production, although I have spent some time recently to create something like a code generator for classes using this object system.

Now I have a question regarding object attributes (such as %name_of, %patent_of in the code below) in a base class. These are not inherited to the derived classes,are they? It seems to me that I cannot access the values of object attibutes of a parent class from within the derived class.

Is use of SUPER disallowed generally in Class:Std?

Must I always redeclare those attributes ( at least those that I intend to use) in the derived class? Wouldn't this result in code duplication?

package Wax::Floor; use Class::Std; { my %name_of :ATTR( init_arg => 'name' ); my %patent_of :ATTR( init_arg => 'patent' ); sub describe :CUMULATIVE { my ($self) = @_; print "The floor wax $name_of{ident $self} ", "(patent: $patent_of{ident $self})\n"; return; } } package Topping::Dessert; use Class::Std; { my %name_of :ATTR( init_arg => 'name' ); my %flavour_of :ATTR( init_arg => 'flavour' ); sub describe :CUMULATIVE { my ($self) = @_; print "The dessert topping $name_of{ident self}", "with that great $flavour_of{ident $self} taste!\n"; return; } } package Shimmer; use base qw( Wax::Floor Topping::Dessert ); use Class::Std; { my %name_of :ATTR( init_arg => 'name' ); my %patent_of :ATTR( init_arg => 'patent' ); sub describe :CUMULATIVE { my ($self) = @_; print "New $name_of{ident $self} (patent: $patent_of{ident + $self})\n", "Combining...\n"; return; } }
The code above is from the Class:Std CPAN documentation (which contains some inconsistencies, by the way.)

I know that Moose is a popular object system. I might indeed try it at a later time.


In reply to OOP/ Class::Std questions by knbknb

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.