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?
For instance, a common concept in filesystems is that deleting a directory is only possible if it's empty. => rmdir
Another that deleting a directory also deletes the containing files. => rm -r
In both cases all "File" objects having weak references to the "Dir" should have been removed.
If that's done automatically in a File:: DESTROY method or only allowed to happen after a $dir->rm call are other design decisions.
The problem here is that the OP's question is to vague to be answered.
If this is all hypothetical and intended for Practice:: instead for a real simulation of a file system, I'd say the topic is too ambiguous to discuss weaken
Especially as I can't even tell that I know all subtle differences between different file systems. Hence there is no "natural" model to copy.
At least, I don't know what a "directory getting deleted after going out of scope" would translate to in "normal practice" ...(?)
Personally I wouldn't allow it to happen.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|