Possibly, and thanks, will have to re-read in the morning when I'm more awake. I feel the isweak method may be the key.

To illustrate the original problem, consider a literal parent, with a child, modelled as 2 classes.

Obviously a parent can have a child, and the child can have that same parent, but that needs to be the weak reference.

When I have a parent and get the child, i store it within the parent, at the same time giving the child a reference back to the parent.

I now know I can always get to one from the other, and if they're not there, simply call a method to get them and store. hey presto, all fine and dandy.

My issue is where I get a child (not needing the parent yet), and WITHIN one of its methods I need to check a property of the parent, i can get the parent fine, check it's property fine, but i feel i should keep a reference so i don't have to get it again later.

Obviously since it's a weak reference from child to parent, it never stays in scope.

Surely that's kinda easy to understand my thoughts, maybe I'm going about it all wrong, but that's how things are starting to be modelled in the system I'm refactoring.


In reply to Re^2: weak-reference set internally by Cagao
in thread weak-reference set internally by Cagao

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.