The compelling case that made me think through how to do it right, rather than avoid it on a case-by-case basis, was in GUI windowing. A window contains a list of its children, and the child points back to its parent. Meanwhile, I was working on asynchronous programming concepts. A "weak reference" can't work if the order of destruction is not defined. This concerned writing the functions that do the acting on input! Basically, WNDPROC in Windows, or closures binding an object and method to call queued to a server thread. When a method is being executed, the object cannot be destroyed. But between, it is fair game, and pending things will fail (guaranteed) as the graph of objects is being taken apart. Basically, think of your query idea as "reference" without using the problematic pointer. I separated the concepts of "reference" from "ownership". Without prompt destruction like I like and depend on in C++, the latter concept might be better described as "dependency".

I agree that most relationships are not explicit because objects act on input rather than being known by each other. But I have small knots of typically 2 objects in this relationship, and the ability to separate the lookup from the use in time due to asynchronous calling.

—John


In reply to Re^4: How to explicitly destroy an object so that all other references to it would become false? by John M. Dlugosz
in thread How to explicitly destroy an object so that all other references to it would become false? by bdimych

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.