[ Obsolete | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

autoload(+Library, ++ListOfPredSpecList)

Declares the predicates in ListOfPredSpec to be autoloading from the module Library, which is in the file Library.pl in one of the library directories.
Library
Atom.
ListOfPredSpecList
of expressions of the form Atom/Integer.

This built-in predicate is obsolete!

Description

Declares the predicates in the list ListOfPredSpec as defined in the file Library. If any of the specified predicates is called, the system looks in the library_path directories for the file Library.pl, compiles it using lib/2 and then re-calls the predicate. The file is supposed to contain a module_interface/1 or begin_module/1 directive at its beginning but it can be omitted and then Library is used as the module name.

Predicates declared as autoloaded are always defined as global but note that the module directive in a file erases the module completely so that the autoloaded procedure (and its visibility) are removed completely before being recompiled. This means that the global declaration must be present in the file.

The predicate autoload_tool/2 is the same except that all the predicates are declared to be tools, using tool/1.

Modes and Determinism

Exceptions

(4) instantiation fault
Library or ListOfPredSpec is not instantiated.
(5) type error
Library is instantiated, but not to an atom.
(5) type error
ListOfPredSpec is instantiated, but not to list a of expressions of the form Atom/Integer.
(173) library not found
Library file Library.pl not found. (when calling an autoloaded predicate)

Examples

Success:
     [eclipse]: get_flag(library_path, Path),
             get_flag(cwd, Cwd),
             set_flag(library_path, [Cwd | Path]).
     Cwd = "/home/user/"
     Path = ["/usr/local/ECLIPSE/lib"]
     yes.
     [eclipse]: open("my_lib.pl", write, s),
      write(s, ":- module(my_lib).\n"),
      write(s, ":- global p/0.\n"),
      write(s, "p :- write(hello).\n"),
        close(s).
     yes.
     [eclipse]: autoload(my_lib, [p/0]).
     yes.
     [eclipse]: p.  % when p/0 is called, the library is
                  % compiled first, ie. autoloaded.
     loading the library /home/user/my_lib.pl
     hello
     yes.
     [eclipse]: p.  % p/0 is not an autoloaded pred anymore
     hello
     yes.

Error:
     autoload(Lib, [p/0]).               (Error 4).
     autoload(a_lib, L).                 (Error 4).
     autoload(a_lib, [1]).               (Error 5).
     autoload(a_lib, p/0).               (Error 5).
     autoload("a_lib", [p/0]).           (Error 5).
     autoload(no_file, [p/0]).           (Error 173).



See Also

ensure_loaded / 1, autoload_tool / 2, lib / 1, lib / 2, tool / 1