I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2008-10-17 17:00:36-07 by jerome
Destroy and inheritance
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
Direct Responses: 9076 | Write a response