Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
In short, I want to invite those who are sufficiently insterested to take a look at and comment on this module. The download link is here. I intend to put the module up on CPAN.

A month ago I put up a meditation Beyond Inside-Out where I sketched a method to do black-box inheritance in Perl without some of the drawbacks of the inside-out technique. The module above is a worked-out version of that sketch. To summarize:

The basis is a function Alter::ego, which retrieves a class-dependent reference associated with an object. A class uses this alter ego for data storage. The Alter::ego and related functions are XS-implemented. The main disadvantage of Alter is that it is an external XS module, while the inside-out technique is pure perl.

The main advantages of Alter over inside-out objects are

  • An unchanged data model

    The alter ego of an object can be any reference. In particular, it can be a hash and the accustomed method of storing object data in hash elements can be maintained. Only now each class gets to see its individual hash.
  • Garbage collection and thread safety

    Perl's normal garbage-collection and thread cloning fully support Alter-based objects. No DESTROY and CLONE methods are required.
  • Support for Data::Dumper and Storable

    Viewing and serializing objects that use out-of-band data storage need support, which Alter provides

    In reply to RFC: Alter - Perl extension for Alter Ego Objects by Anno

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



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others scrutinizing the Monastery: (4)
    As of 2024-04-25 19:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found