On Fri, Jul 07, 2000 at 04:07:12PM -0400, Michael G Schwern wrote:
> On Fri, Jul 07, 2000 at 03:19:29PM +0100, Graham Barr wrote:
> > I have not looked at the code, but I assume it works by Class::WhiteHole 
> > defining an AUTOLOAD sub which just dies. 
> 
> Pretty much.  You have to do a few tricks for DESTROY and to make sure
> the right error message shows up (all of which I forgot to do in 0.01
> *sigh*)
> 
> > If so then I would consider a
> > patch to AutoLoader.pm which allows
> > 
> >   no AutoLoader;
> 
> That was along the lines of my first thought, too.  Problem is when
> used naively, no AutoLoader could severely screw things up.  Consider:
> 
> package Foo;
> 
> use AutoLoader qw(AUTOLOAD);
> @ISA = qw(AutoLoader);
> 
> sub public_bar {
>     my($self) = shift;
>     return $self->_autoloaded_private_method();
> }
> __END__
> sub _autoloaded_private_method {
>     return 'whatever';
> }
> 
> 
> # Meanwhile, in a nearby file
> package Bar;
> 
> use base qw(Foo);
> no AutoLoader;
> 
> # Ooops, public_bar() can't autoload _autoloaded_private_method()
> # because we blocked reaching AutoLoader from Bar.
> Bar->public_bar;

This is not true. Perl will first look for Foo::AUTOLOAD because there is
a stub for _autoloaded_private_method created by AutoSplit when the
module is installed.

Perl will only look for AUTOLOAD via @ISA if it cannot find a stub for the method
or there is no AUTOLOAD in the package where the stub exists.

Graham.

Reply via email to