On Thursday, October 17, 2002, at 09:58 AM, NYIMI Jose (BMB) and Jeff 'japhy' Pinyan wrote:
This doesn't support multiple inheritance, which will be needed to use this class as the "mixin" it is intended to be.On Oct 17, James Edward Gray II said:sub new { my $class = shift; $class = ref $class if ref $class; my %args = @_; my $self = bless { }, $class;# needs hierarchical initialization here $self->initialize(%args); return $self; }$self->SUPER::initialize(%args);
This calls the object's initialize method repeatedly, not the initialize of the parent objects.{ no strict 'refs'; # sorry, but it's a bit more convenient this way for (@{ "${class}::ISA" }) { $self->initialize(%args); } }
Using these, I got close, I think. I now have:
my %seen = (__PACKAGE__, 1); # to keep this class from being called
{
no strict 'refs';
$_->initialize(%args) foreach (grep !$seen{$_}++, @{ "${class}::ISA" });
}
$self->initialize(%args); # the actual object
Unfortunately this doesn't quite get it done either. It does call the initialize method of the parents, but the don't get passed an object to modify. I just can't seem to get my head around this one, so any more tips are definitely welcome. Thanks again.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]