PackageDescription | Autoloading is a very powerful mechanism for dynamically handling function
calls that are not defined. However, its implementation is very
complicated. For the simple case where you wish to allow method calls to
methods that don't yet exist, this module allows you to define an 'AUTOCAN'
method which will return either a code reference or 'undef'.
Autoload::AUTOCAN installs an 'AUTOLOAD' subroutine in the current package,
which is invoked when an unknown method is called. The installed 'AUTOLOAD'
will call 'AUTOCAN' with the invocant (class or object the method was
called on) and the method name. If 'AUTOCAN' returns a code reference, it
will be called with the same arguments as passed to the unknown method
(including the invocant). If 'AUTOCAN' returns 'undef', an error will be
thrown as expected when calling an undefined method.
Along with 'AUTOLOAD', the module installs a 'can' method which returns
code references as normal for defined methods (see UNIVERSAL), and
delegates to 'AUTOCAN' for unknown methods. |