Forsaken has asked for the wisdom of the Perl Monks concerning the following question:
yet another puzzle which has been occupying my thoughts for a while, is it (considered) bad practice for a package to store references to its objects somewhere? For example:
The consequence of this would be that the code creating the Foo object cannot simply dereference it to invoke destruction. Obviously good documentation and a special method to get rid of objects is all it takes to circumvent the issue, but my question is still: is this "not done"?package Foo; use strict; use warnings; my %objects; sub new { my $class = shift; my $self = {}; bless($self, $class); $objects{$self} = *some vitally important information*; return $self; }
I'd very much appreciate to hear your insights.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storing object references internally
by bart (Canon) on Apr 23, 2005 at 09:15 UTC | |
by Forsaken (Friar) on Apr 23, 2005 at 09:18 UTC | |
by bart (Canon) on Apr 23, 2005 at 09:28 UTC | |
|
Re: Storing object references internally
by basje (Beadle) on Apr 23, 2005 at 09:16 UTC | |
|
Re: Storing object references internally
by Tanktalus (Canon) on Apr 23, 2005 at 14:34 UTC | |
|
Re: Storing object references internally
by zentara (Cardinal) on Apr 23, 2005 at 11:36 UTC | |
|
Re: Storing object references internally
by tlm (Prior) on Apr 23, 2005 at 13:10 UTC | |
|
Re: Storing object references internally
by DrHyde (Prior) on Apr 25, 2005 at 08:45 UTC |