[ ECLiPSe Predicate Database built-in.|Group Index| Full Index]

lib(+LibraryName,+ModuleName)

The library LibraryName is loaded into the module ModuleName if not loaded already.

+LibraryName
String or Atom.
+ModuleName
Atom.

Description

Used to load the system library LibraryName into the module ModuleName if it has not already been loaded. The currently defined Prolog suffix(es) is appended to LibraryName and the resulting library is loaded if it can be found in the directories specified by the library path.

The search path used when loading libraries is specified by the global flag library_path using the get_flag/2 and set_flag/2 predicates. This flag contains a list of strings containing the pathnames of the directories to be searched when loading a library file. User libraries may be added to the system simply by copying the desired file into the ECLiPSe library directory. Alternatively the library_path flag may be updated to point at a number of user specific directories.

lib(Lib, Mod) is similar to use_module_body(library(Lib), Mod), however with lib/2 it is possible to load files that do not contain any module definitions or those with a different name than the file name. Another difference is that lib/2 uses ensure_loaded/2 to load the file and so it is recompiled if the file has been modified.

Fail Conditions

None

Resatisfiable

No

Exceptions

(4) Instantiation fault
LibraryName is not instantiated.
(5) Type error
LibraryName is neither a string nor an atom.
(173)
The library file LibraryName cannot be found.

Examples


Success:
   [eclipse]: lib(utilities, utils).
   loading the library /home/lp/icl/prolog/utilities.pl
   yes.
Error:
   lib(fred,Y).       (Error 4)
   lib(sorts,1).      (Error 5)
   lib(no_lib,lib).   (Error 173)

See Also

ensure_loaded / 1, lib / 1, get_flag / 2, set_flag / 2, use_module / 1