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

+DefModule : +Goal

Goal is executed using the predicate definition in DefModule rather than the visible one.

+Goal
Callable term (atom or compound).
+DefModule
Atom.

Description

This predicate provides a means to override the module system's visibility rules. While normal calls, as well as the builtins call/1 and @/2 all call the predicate that is _visible_ from the caller's module, :/2 allows to call a predicate which is _defined_ in a certain module (note that there different modules may have different definitions for a predicate of the same name, but only one of them will be visible in each module).

This allows calling a predicate that is otherwise not visible (i.e. not imported) in the caller module. The two main uses of this facility are: 1. If there are several definitions of a predicate with the same name in different modules, :/2 can be used to specify which one to call.

2. If a module wants to define a predicate, but needs to call another predicate 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 can only call exported or global predicates in order to preserve module privacy.

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)
Goal is an undefined procedure in Module.

Examples


     [eclipse]: cd(~).
     system interface error: No such file or directory in cd(~)

     [eclipse]: [user].         % redefine cd/1, using its
                                % original definition
      cd(~) :- !,
               getenv('HOME', Home),
               sepia_kernel:cd(Home).
      cd(Dir) :-
               sepia_kernel:cd(Home).

      [eclipse]: cd(~).
      yes.



See Also

call / 1, @ / 2, export / 1