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?

That's one of the reasons why I wrote that it depends on design decisions

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.

Update

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

  • Comment on Re^2: Should I use weaken on an object attribute containing a reference to an object which contains reference back to original object?
  • Select or Download Code