[ ECLiPSe Module built-in.|Group Index| Full Index]

use_module(+Module)

Make available the interface of Module.

+Module
Atom or compound term library(Atom)

Description

This predicate is used to make available the module interface of another module. If Module does not exist, the system tries to find file with the name equal to Module, possibly appending a suffix from the prolog_suffix flag. If Module is an atom, it looks for the plain file name; if Module is of the form library(File), it prepends directories from the library_path flag to File. Module can also be a pathname and in this case the module is equal to the last component of the path. If no such readable file is found, the predicate looks for a directory with the name equal to the module name and tries to find the file there. The file must contain a module of the same name. The file is compiled and then, or if the module already exists, import(module) is executed and thus all exported predicates and other interfaces of Module are made available in the caller module. Finally, if a procedure module_initialization/1 is defined in Module, it is executed with the caller module as argument.

Fail Conditions

Fails if the compilation of the file fails or if the file does not contain the specified module.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
Module is not instantiated.
(5) Type error
Module is instantiated, but not to an atom.
(80)
Module is not defined in the compiled file.
(82)
Module is locked.
(149)
Raised before compiling the file.
(173)
The file does not exist or is not readable.

Examples


Success:
    use_module(library(check)).
    use_module('/use/local/eclipse/lib/check').

    [eclipse 2]: X::1..10.
    syntax error: postfix/infix operator expected
    | X::1..10.
    |   ^ here
    [eclipse 2]: use_module(library(domain)).
    /usr/local/eclipse/lib/structures.pl compiled optimized 2532 bytes in 0.05 seconds
    /usr/local/eclipse/lib/domain.sd compiled optimized 50328 bytes in 1.13 seconds

    yes.
    [eclipse 3]: X::1..10.

    X = X :: [1 .. 10]
    yes.

Error:
     use_module(M).                      (Error 4).
     use_module(file(f)).                (Error 5).



See Also

begin_module / 1, compile / 1, ensure_loaded / 1, import / 1, lib / 1, module_interface / 1