True inside-objects, your classes are not.

One of the points of inside-out objects is that the references do not point to anything used by the inside-out classes. Only the address is used, and nothing else. Your objects rely on the fact they are hash references, and rely on the key __PACKAGE__. This means you are breaking encapsulation. A subclass can fiddle with the internals (by accident) and you are denying your subclasses any implementation that deviates from being a hashref.

Threads within a process all share the same address space.
Is that true on every platform? Will that always be true, even in a next version or Perl? I don't think Perl gives you that promise; I would hence not rely on it.

But if you're going to store the keys in the object themselves, why bother with the refaddress of which you aren't sure it's going to work? Just use a random number, and if it's already used in %class_records, pick another one. Or use a counter.

BTW, from your code fragment, I don't understand what the role of $class_objects is.

Of course, the easy way is to upgrade to 5.10. Then you can use fieldhashes, and everything will be done for you.


In reply to Re: Are Addresses From refaddr Unique Across Threads? by JavaFan
in thread Are Addresses From refaddr Unique Across Threads? by aecooper

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.