Like any piece of art the trick it knowing when to stop. You went one step too far here. Your code reference should not be blessed and the incant method is completely superfluous. I'd normally prefer to write that sort of thing as $obj -> ( 'method', @args ) since that's really what is happening anyway. The only thing you lose is the blessing's inheritance tree but you didn't mention that so I'm not sure if you even intended to use it. Personally I'm looking at your implementation as a way of getting to classless objects. All you really need here is the code reference - you just call it with the method/property name as a parameter to the object.


Also, some comments on style:

 $class = ref($class) || $class;

How about quiting the cargo cult line? For your concept it really doesn't fit here.

for (keys %$props) { $props->{$_} = $colors{$_}; }

Better done as a hash slice - your existing form is much less readable than it could be. Clearer: @{$props}{ keys %$props } = @colors{ keys %$props }


In reply to Re: AbstractClassFactory by diotalevi
in thread AbstractClassFactory by hypochrismutreefuzz

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.