So I started writing some OO code. I designed my objects and started writing an AUTOLOAD to create data accessors. I knew I wanted to do some pretty funky stuff, so I figured Class::MakeMethods and company probably wouldn't be quite as flexible as I needed them to be. After reading the docs and writing some sample code though, I think I might change my mind. The problem is though that one of the things my code does doesn't seem to be in any of the method generating modules I've looked at so far.

My objects (implemented as hashes) have some keys that are associated with references to other hashes. The keys in those hashes in turn point to references to objects. Such a structure just doesn't seem to be available in Class::MakeMethods, etc. They have methods for arrays of objects and tied hashes of objects, but no simple hashes of objects.

Is there something that I'm missing? Is there some reason that it makes no sense to do what I'm doing? I can just use the plain old hash methods and hack up some way to handle delegation, or I can use the array of objects methods and hack up some sore of indexing functionality with hooks in the data accessors to update the indexes, but that seems like more work that it should be if I'm using a general purpose method making module... *sigh*

Maybe I should go back to writing ten tons of closures for my cacheing AUTOLOAD. Anyone want to drop some Wisdom™ on me?


In reply to Why isn't it in Class::MethodMaker or Class::MakeMethods? by Orsmo

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.