in reply to Re: Should I use weaken on an object attribute containing a reference to an object which contains reference back to original object?
in thread Should I use weaken on an object attribute containing a reference to an object which contains reference back to original object?
As I already said, this is a design problem of this "file system simulation" , and not weaken's
I have trouble imagining a file system where dirs and files are deleted implicitly after "falling out of scope".
Personally I would make deletion explicit with ->remove methods, and keep strong refs of the objects only in an %instance hash of the class, all other internal refs must be weak. Like this the refcount can not become 0 unless explicitly wanted.
Now if there are still other external refs when ->remove is called, this must be resolved.
Either they are all weak, because the constructor returned them weak and they'll become automatically undef after distruction.
Or they are strong and the refcount is checked by ->remove and throws an error "can't remove, still in use"
Bottom line: This scenario is too complicated to discuss weaken
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Should I use weaken on an object attribute containing a reference to an object which contains reference back to original object?
by hippo (Archbishop) on Jan 23, 2024 at 14:48 UTC | |
by LanX (Saint) on Jan 23, 2024 at 15:12 UTC | |
|
Re^3: Should I use weaken on an object attribute containing a reference to an object which contains reference back to original object?
by ikegami (Patriarch) on Jan 23, 2024 at 00:51 UTC | |
by LanX (Saint) on Jan 23, 2024 at 03:37 UTC | |
by ikegami (Patriarch) on Jan 23, 2024 at 03:41 UTC |