[ Control | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
+LookupModule : +Goal
Call the procedure visible in LookupModule rather than the caller module
- +Goal
- Callable term (atom or compound).
- +LookupModule
- Atom.
Description
This predicate provides a means to invoke a procedure which is not visible.
Normally, when a procedure is called, the system looks for a visible
definition (local or imported) in the caller module. This primitive
on the other hand allows to specify a different lookup module.
Two conditions must be satisfied for the lookup to succeed:
- the definition wanted must be visible in the lookup module
- the definition wanted must be exported from its home module
The purpose of this is to allow calling procedures whose definition is
not visible in the caller module. The two main uses of this facility are:
- If there are several definitions of a procedure with the same name
in different modules, :/2 can be used to specify which one to call.
- If a module wants to define a procedure, but needs to call
another procedure of the same name (but from a different module),
:/2 can be used to call that one instead of the locally defined one.
Note that :/2 does not affect the caller (context) module.
The following table summarises the different idioms:
Call within module(m) lookup module caller module
..., twice(X), ... m m
..., lm : twice(X), ... lm m
..., twice(X) @ cm, ... m cm
..., lm : twice(X) @ cm, ... lm cm
..., call(twice(X)) @ cm, ... cm cm
Note: In earlier versions of Eclipse the left hand side argument of
:/2 was required to be the module where the procedure was defined,
rather than just visible.
Fail Conditions
Fails if Goal fails.
Resatisfiable
No.
Exceptions
- (4) instantiation fault
- Goal is not instantiated.
- (4) instantiation fault
- Module is not instantiated.
- (5) type error
- Goal is neither an atom nor a compound term.
- (5) type error
- Module is not an atom.
- (68) calling an undefined procedure
- Goal is an undefined procedure in Module.
Examples
% two definitions are visible:
:- lib(ria). % exports #>= / 2
:- lib(eplex). % exports #>= / 2
..., ria:(X #>= Y), ...
..., eplex:(X #>= Y), ...
% the library predicate is hidden by the local definition:
:- lib(lists). % exports print_list/1
print_list(List) :-
writeln("This is the list:"),
lists:print_list(List).
See Also
call / 1, @ / 2, export / 1