on 2/5/02 3:52 PM, [EMAIL PROTECTED] purportedly said: In general, what is the needd for the additional subclass, and how would it be constructed such that its destructor is always called first? It would seem that it is just easier to undef the child object(s) and let Perl take care of the parent, but I am trying to avoid that, since it makes the code pretty convoluted.
> 1) call the base class' destructor yourself > package subsubclass; > sub DESTROY { > my $self = shift; > $self->subclass::DESTROY(); > $self->class::DESTROY(); > } But since I can't control the order of destruction, I would have to call the subsubclass destructor explictly. Additionally, how does it know which object(s) to destroy--or does it destroy all objects for the class? > 2) generalize 1) > package subsubclass; > sub DESTROY { > my $self = shift; > foreach my $parent ( @ISA ) { > my $destructor = $parent->can("DESTROY"); > $self->$destructor() if $destructor; > } > } Isn't this just calling the parent class' destructor explicitly? > 3) rebless, works only if you don't have multiple inheritance > package subsubclass; > sub DESTROY { > my $self = shift; > bless $self, $ISA[0]; > } > package subclass; > ... > bless $self, $ISA[0]; > Keary Suska Esoteritech, Inc. "Leveraging Open Source for a better Internet"