next up previous
Next: Dynamic Modules Up: Meta-Predicates in Modules Previous: Definition and Context

Overruling Module Boundaries


The mechanism above is sufficient to create an acceptable module system. There are however cases in which we would like to be able to overrule this schema and explicitely call a predicate in some module or assert explicitly in some module. The first is useful to invoke goals in some module from the user's toplevel or to implement a object-oriented system (see above). The latter is useful to create and modify dynamic modules (see section gif).

For this purpose, the reserved term :/2 has been introduced. All built-in predicates that transform a term into a predicate reference will check whether this term is of the form `<Module>:<Term>'. If so, the predicate is searched for in Module instead of the goal's context module. The :/2 operator may be nested, in which case the inner-most module is used.

The special calling construct <Module>:<Goal> pretends Goal is called from Module instead of the context module. Examples:

?- assert(world:done).	% asserts done/0 into module world
?- world:assert(done).	% the same
?- world:done.		% calls done/0 in module world

Passani Luca
Tue Nov 14 08:58:33 MET 1995