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":



  • 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.