AUTOLOAD
Ovid
publiustemp-londonpm at yahoo.com
Tue Jan 16 15:19:58 GMT 2007
--- Dirk Koopman <djk at tobit.co.uk> wrote:
> > Of course it's possible. As already mentioned on this thread
> Class::Std
> > implements a solution to the problem too. The point is that there's
> no
> > *standard* way to percolate unhandled AUTOLOADs up the inheritance
> > chain. If you allow for the possibility of multiple inheritance
> it's not
> > entirely trivial to do either.
>
> Er.. are you sure? AFAIK AUTOLOAD will simply use the *standard*
> inheritance rules as documented in perloo et al.
It sort of does, but check this out:
--- Dirk Koopman <djk at tobit.co.uk> wrote:
> > Of course it's possible. As already mentioned on this thread
> Class::Std
> > implements a solution to the problem too. The point is that there's
> no
> > *standard* way to percolate unhandled AUTOLOADs up the inheritance
> > chain. If you allow for the possibility of multiple inheritance
> it's not
> > entirely trivial to do either.
>
> Er.. are you sure? AFAIK AUTOLOAD will simply use the *standard*
> inheritance rules as documented in perloo et al.
It sort of does, but check this out:
#!/usr/bin/perl
use strict;
use warnings;
{
package Parent;
sub AUTOLOAD { print "In Parent\n" }
package Child::A;
our @ISA = 'Parent';
sub AUTOLOAD {
my $proto = shift;
print "In Child::A\n";
$proto->SUPER::AUTOLOAD();
}
package Child::B;
our @ISA = 'Parent';
sub AUTOLOAD {
my $proto = shift;
print "In Child::B\n";
$proto->SUPER::AUTOLOAD();
}
package GrandChild;
our @ISA = qw<Child::A Child::B>;
sub AUTOLOAD {
my $proto = shift;
print "In GrandChild\n";
$proto->SUPER::AUTOLOAD();
}
}
GrandChild->whee;
You can never class the AUTOLOAD in Child::B. That could very well be
undesired behavior.
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/
More information about the london.pm
mailing list