|
If I understand the code correctly, it looks like during InsideOut::Object::DESTROY, the various methods tagged with ':Destroy' in each class forming the inheritance tree are going to get called from child to parent immediately followed by the deletion of the fields of each class. This prevents the :Destroy method of a parent from executing any methods of a child that would rely on that child's fields. In the simple example below, the message displayed during destruction of $o is not going to display the string you'd expect from 'get_description' since $f[$$self] has been deleted already.
package a;{
use Object::InsideOut;
sub _destroy :Destroy {
my $self = $_[0];
print "Destroy of " . $self->get_description;
}
sub get_description {
return __PACKAGE__ ;
}
}
package a::b;{
use Object::InsideOut qw(a);
my @f :Field :Get(get_f);
sub _init :Init {
my $self = $_[0];
$f[$$self] = 1;
}
sub get_description {
my $self = $_[0];
return __PACKAGE__ . " with f = $f[$$self]";
}
}
my $o = a::b->new;
undef $o;
Is there anyway the class fields could be deleted only *after* all the :Destroy subroutine have run? Or am I misunderstanding the problem?
Jerome |