Yes weakrefs() are one thing that causes DDS a lot of problems, they completely screw DDS and there really is nothing I can do about it.

As for the advice that weakrefs are the correct way to do self referential structures, I disagree. There really is no reason to require weakrefs and in fact IMO when you design self referential structures without using weakrefs you get certain benefits that are available when you do not use weakrefs.

The central idea is that you use a stub object that isnt part of the self referential structure as the root or container of the structure. Since the root is not part of the reference cycle its refcount will decrement properly when it falls out of use, which will then trigger the DESTROY{} method which will then traverse the structure and eliminate the reference cycles. This is a useful design anyway as you can now use the root for various bookeeping efforts like how many nodes their are, different entry points into traversing the structure, even state information for things like iterators. All of these latter things are impossible or very difficult to accomplish with a "no container class using weakrefs" type data structure.

---
demerphq


In reply to Re^9: In need of a Dumper that has no pretentions to being anything else. by demerphq
in thread In need of a Dumper that has no pretentions to being anything else. by BrowserUk

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.