I have 3 classes creating a hierarchy...
Foo
Bar
Baz
Foo is the top-most parent.
Each object has an accessor to it's possible child ($bar->baz), and a private accessor to its possible parent ($bar->_foo).
The parents and children are not compulsary, ie, to get a 'Bar' you don't need to automatically grab it's parent 'Foo' nor it's child 'Baz'.
The private accessors to their parents are obviously all weak-references.
Now here's the problem...
Within $bar->a_method() I need to get it's parent Foo object, so get one and store it in $bar->_foo for later possible use.
Obviously the moment I leave $bar->a_method, the parent Foo object has gone out of scope, and due to the weak-reference, I lose it in the parent accessor.
Turning off the weak reference in this case works for now, but in the future I may well have the Foo object created elsewhere, and also copied to the private parent accessor, so will need the weak-ref.
Any idea's of possible solutions?
(This is in Moose incase it makes any difference).
In reply to weak-reference set internally by Cagao
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |