AUTOLOAD

Dirk Koopman djk at tobit.co.uk
Tue Jan 16 16:10:06 GMT 2007


Andy Armstrong wrote:
> On 16 Jan 2007, at 14:36, Dirk Koopman wrote:
>> Not that I have tried it ever (because I don't generally need to go 
>> there) but why can one not call SUPER::AUTOLOAD? AUTOLOAD is just a 
>> method (albeit a special one with an extra calling convention) after all?
> 
> Nope. See:
> 
> http://search.cpan.org/~tilly/Class-AutoloadCAN-0.03/lib/Class/AutoloadCAN.pm 
> 
> 
>    "This module solves a fundamental conflict between AUTOLOAD, can and
>     inheritance. The problem is that while you can implement anything in
>     AUTOLOAD, UNIVERSAL::can is not aware that it is there. Attempting to
>     modify UNIVERSAL::can to document those methods is very hard. And if a
>     parent class uses AUTOLOAD then subclasses have to do a lot of work to
>     make their AUTOLOADs cooperate with the parent one. It is harder still
>     if 2 parent classes in a multiple inheritance tree wish to cooperate
>     with each other. Few try to do this, which may be good since those who
>     try usually get it wrong."
> 

Look: Nowhere in my reply did I mention anything about any flavour of 
can(). I was stating my belief that AUTOLOAD is a normal method in so 
far as it observes normal perl (multiple) inheritance rules. When 
messing with AUTOLOAD, the only thing that can() and its friends can 
tell you, reliably, about is any static method - such as 
$foo->can('AUTOLOAD').

And Ovid has answered my other question: which is that you can 
successfully call $foo->SUPER::AUTOLOAD and it will do as I expect. 
However, not that I intend to go there (as previously mentioned).

Dirk





More information about the london.pm mailing list