http://qs1969.pair.com?node_id=521997

Building on several recent threads on inside-out objects, I've recently released an "alpha" version of a simple, safe and streamlined toolkit for building inside-out objects called Class::InsideOut.

Compared to other inside-out object building modules already on CPAN, this module aims for minimalism and robustness:

The goal of Class::InsideOut is to provide the minimal support necessary for creating safe inside-out objects. All other implementation details, including writing a constructor and managing inheritance, are left to the user. More advanced builders could be written on top of Class::InsideOut, of course.

For example, here is a very simple class:

package My::Class; use Class::InsideOut qw( property register id ); # declare a lexical property hash with 'my' property my %name; sub new { my $class = shift; my $self = \do {my $scalar}; bless $self, $class; # register the object for thread-safety register( $self ); } sub get_name { my $self = shift; # optional 'id' as alias to Scalar::Util::refaddr return $name{ id $self }; } 1; # modules must be true

For a more complete description of the philosophy, design, and interface, please see the Class::InsideOut documentation. The documentation includes a comparison to other inside-out object generators on CPAN. Of the various modules, the one that is closest to this is Object::InsideOut, which I recommend for a more full-featured approach.

(At the risk of straining a simile, perhaps, Class::InsideOut is supposed to be like a Honda Civic -- basic and dependable. Object::InsideOut is more like a Porsche -- designed for speed and style. I see the two as complements, not competitors.)

As the basic inside-out feature set is working and code-coverage is high, Class::InsideOut needs some field testing. I encourage fellow monks to download it, give it a test drive and offer some feedback. To those with enough expertise to find implementation weaknesses, I would particularly welcome your insights. (In particular, I'd greatly appreciate if someone could give it a spin under mod_perl and some Storable-compatible session manager, as I don't have an environment for those handy to test.)

Thanks!

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.