Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^8: In need of a Dumper that has no pretentions to being anything else.

by BrowserUk (Patriarch)
on Feb 24, 2005 at 04:26 UTC ( [id://433944]=note: print w/replies, xml ) Need Help??


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

DDS avoids these problems by traversing the data structure twice using the refcounts to determine what it needs to keep an eye on...

If I am building a data structure that intentionally contains self references and I follow the advice for avoiding memory leaks by using Scalar::Util::weaken(), will that have a bad affect upon your heuristic?


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
  • Comment on Re^8: In need of a Dumper that has no pretentions to being anything else.
  • Download Code

Replies are listed 'Best First'.
Re^9: In need of a Dumper that has no pretentions to being anything else.
by demerphq (Chancellor) on Feb 24, 2005 at 07:54 UTC

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://433944]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-23 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found