use_module/3

use_module(+Files, +Imports)* loads a module file but only imports the named predicates

use_module(? M,? F,+ L)*

This predicate loads the file specified by Files, importing their public predicates specified by Imports into the current type-in module. It is implemented as if by:


 use_module(Files, Imports) :-
 load_files(Files, [if(not_loaded),must_be_module(true),imports(Imports)]).

The Imports argument may be use to specify which predicates one wants to load. It can also be used to give the predicates a different name. As an example, the graphs library is implemented on top of the red-black trees library, and some predicates are just aliases:


 :- use_module(library(rbtrees), [
 @ref rb_minU2fU_3 "rb_min//3" 3 as min_assoc,
 @ref rb_maxU2fU_3 "rb_max//3" 3 as max_assoc,

 ...]).

Unfortunately it is still not possible to change argument order.

SICStus directive for loading a module, it can operate in two different ways:

  1. If the module M is given, import the procedures in L from M to the current source module.

  2. Otherwise, operate as use_module//22, and load the files specified by F, importing the predicates specified in the list L.