I've been having lots of fun lately creating complex classes which inherit from PDL. Unfortunately, when PDL creates objects on the fly, e.g. when it needs to store the result of an operation:
$mpdl = MyPDL->new; $npdl = $mpdl + 1; # $npdl will be of class MyPDL it can't pass along any additional parameters to the constructer. This can cause a problem if the object's attributes cannot be given default values, as the constructed object will be incomplete. For example, I've got some polymorphic code which handles MyPDL's differently from PDLs. In the above example, when passed $npdl it thinks it's a MyPDL object, but required attributes aren't set, and things explode. Things would be easier if $npdl were constructed as a plain piddle. The actual code to do this isn't complicated, but it may not be obvious how to apply it when using one of the class frameworks (such as Moo, Class::Tiny, etc.), so I've whipped up a simple distribution, PDLx::DetachedObject. For now it's just up at github & bitbucket: https://github.com/djerius/PDLx-DetachedObject https://bitbucket.org/djerius/pdlx-detachedobject The module includes a more detailed writeup of what's going on; I'd appreciate comments and corrections! Thanks, Diab ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel