I'm in the middle of designing support for serializing singletons with Storable in Class::InsideOut -- which will be the last feature before 1.0.

I could benefit greatly by hearing some examples and opinions for any or all of these questions:

  1. How do you use singleton objects currently?
  2. Do you serialize them? If so, how?
  3. When thawing, if no singleton has yet been created, how do you regenerate the singleton from frozen values?
  4. If a thawed singleton "conflicts" with an existing singleton, how do you resolve that conflict?

References to specific modules or applications where I could see code would be very useful, too.

For those who don't understand why serializing singletons is a tricky proposition with Storable, it revolves around the necessary limitations of the STORABLE_attach hook. Here are a few references about it here and on RT:

Advice and insights on this topic would be greatly appreciated.

-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.


In reply to Storable singletons by xdg

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.