"Michael A. Chase" <[EMAIL PROTECTED]> writes:

> Here's a patch that will let HTML::Treebuilder work for now.

Good to see that somebody is awake when I'm asleep :-)

> It looks like we need to add an initializer to HTML::Parser or HTML::Element
> to allow one to initialize objects of the other's class.  Adding the
> initializer to HTML::Element would probably  be easier.

Yes, separating the object allocation from the initialization is
probably a good idea in general.  Especially when multiple inheritance
comes to play.

package A;  # and similar for B

sub new
{
   my $class = shift;
   my $self = bless {}, $class;
   return $self->init(@_);
}

sub init
{
   my($self, %arg) = @_;
   $self->{some_field} = "foo";
   #...
   $self;
}

package AB;
use base qw(A B);

sub init
{
   my($self, %arg) = @_;
   $self->A::init(%arg);
   $self->B::init(%arg);
   $self;
}

Given that we have not done it before, I am not sure we really want to
do it now.  Copying the fields like both your and mine patch did works
good enough I think.

> Do we have a memory leak when a reblessed reference to a HTML::Parser object
> is reassigned?

I am not sure what you are thinking of here.

We get a memory leak if the HTML::Parser destructor is not called
somehow.  This might be caused by a subclass overriding DESTROY, but
not calling SUPER::DESTROY or by reblessing the object to some class
that don't @ISA HTML::Parser.  This should probably have been
explained in the SUBCLASSING section of the HTML::Parser POD.

Regards,
Gisle

Reply via email to