Dan Sugalski wrote in perl.perl6.internals :
> 
> In Perl terms, assume we have a method PRE that gets called before 
> any method in a class is called, and AUTOLOAD which is called if you 
> call a method on a class and that method doesn't exist. Does AUTOLOAD 
> have to get called to check for PRE if PRE doesn't exist in a class?

In Perl 5, AUTOLOAD is called for destructors :

    $ perl -wle 'sub AUTOLOAD{print $AUTOLOAD};bless{}'
    main::DESTROY

While I think this is annoying in most cases, I imagine this may be
useful. And adding an empty destructor to a class is not a huge effort.

The situation is similar for a PRE method. If it's not defined, there's
no error ; if it's not defined but if AUTOLOAD exists, AUTOLOADing is
tried. (I imagine that if AUTOLOAD gracefully refuses to create the PRE
method, no further attempt will be made.)

Reply via email to