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

Goal @ ContextModule

Goal is executed in the calling context of ContextModule.

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

Description

The calling context of a goal is normally the module where the goal is called. @/2 allows to specify this context module explicitly. This is needed when writing meta-predicates (i.e. predicates which have goals or predicates as their arguments) or predicates which depend otherwise on the module system's visibility rules.

@/2 differs from call/2 insofar as it only changes the calling context of the goal, but the goal predicate is still looked up in the module where @/2 is called. As opposed to that, call/2 changes both lookup and context module.

If Goal is not a tool-predicate, then Goal@ContextModule is completely equivalent to Goal.

Fail Conditions

Fails if Goal fails.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
Goal is not instantiated.
(5) Type error
Goal is neither an atom nor a compound term.
(68)
Goal is an undefined procedure in the caller module.

Examples


    [eclipse 1]: [user].
     :- tool(where/0, where/1).
     where(Module) :-
        printf("where/0 was called from module %w\n",
         [Module]).
    ^D
    [eclipse 2]: where.
    where/0 was called from module eclipse
    yes.
    [eclipse 3]: where @ m.
    where/0 was called from module m
    yes.
    [eclipse 4]: call(where, m).
    calling an undefined procedure where in module m
    [eclipse 1]: [user].
     :- tool(print_local_preds/0, print_local_preds/1).
     print_local_preds(Module) :-
            current_predicate(P) @ Module,
            get_flag(P, visibility, local) @ Module,
            writeln(P),
            fail.
    ^D
    [eclipse 2]: print_local_preds.
    print_local_preds / 0
    print_local_preds / 1


See Also

: / 2, call / 2, tool / 2