[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: Proposal: Deterministic Object Destruction

On Wednesday, February 28, 2018 at 11:44:39 PM UTC-6, Paul Rubin wrote:
> Rick Johnson <rantingrickjohnson at gmail.com> writes:
> > Can you provide a real world example in which you need an
> > object which circularly references _itself_?
> DOM trees are a classic example (see the various DOM
> modules in the Python stdlib).  Non-leaf nodes have a list
> of child nodes, child nodes have pointers back upwards to
> their parent, and each child node has pointers to its left
> and right siblings if they exist.  It's all very circular.

Hmm, Yes. I am familiar with these types of tree structures.
But i don't remember encountering any nodes which explicitly
referenced _themselves_ in the manner that Chris presented:

    class Node(object):
        def __init__(self):
            self.self = self
            self.children = []

True, each node may possibly save a reference to a parent
node, and also contain N child nodes (either proxies or
actual instances) but not something akin to what Chris
presented earlier in this thread.

But if i missed something, feel free to elaborate...