mhm. Is that an issue of subclassing, of aggregation, or of mutiple inheritance? Difficult to tell
without synopsis.
See Anno's Alter package (RFC: Alter - Perl extension for Alter Ego Objects); may be that only adds to the confusion, but
I have a gut feeling it addresses your problem. Maybe I'm wrong.
If what you are doing is "method aggregation" (sorry for not using/knowing the canonical term for that),
- if you want to call a method based on an object's attribute, you could just use that attribute
to handle method dispatch via AUTOLOAD (which more aptly should be called AUTODISPATCH, since
loading is only one use for it, as in AutoLoader). The loading of that attribute's package would
have to be done in the object constructor.
Example:
sub AUTOLOAD {
return if $AUTOLOAD eq __PACKAGE__.'::'.'DESTROY';
my $self = shift;
(my $func = $AUTOLOAD) =~ s/.*:://;
if ($self->{extension}) {
my $method = join '::', __PACKAGE__, $self->{extension}, $func
+;
$method->($self,@_);
}
else {
die "method $func not defined for $self\n";
};
}
But that has the strong smell of reinventing a wheel. Method lookup based on object attribute? hmm...
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|