6.4 Controlled autoloading for modules
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Modules
        • Controlled autoloading for modules
          • autoload/1
          • autoload/2
    • Packages
Availability:built-in
Sourceautoload(:File)
autoload(:File, +Imports)
Declare that possibly missing predicates in the module in which this declaration occurs are to be resolved by using use_module/2 on File to (possibly) load the file and make the target predicate available. The autoload/2 variant is tried before autoload/1. It is not allowed for two autoload/2 declarations to provide the same predicate and it is not allowed to define a predicate provided in this way locally. See also require/1, which allows specifying predicates for autoloading from their default location.

Predicates made available using autoload/2 behave as defined predicates, which implies that any operation on them will perform autoloading if necessary. Notably predicate_property/2, current_predicate/1 and clause/2 are supported.

Currently, neither the existence of File, nor whether it actually exports the given predicates (autoload/2) is verified when the file is loaded. Instead, the declarations are verified when searching for a missing predicate.

If the Prolog flag autoload is set to false, these declarations are interpreted as use_module/[1,2].