next up previous index
Next: Mapping between C Up: External Language Interface Previous: External Language Interface

External Procedures

  What is an external procedure? An external procedure is a subprogram written in a language other than Prolog, which imitates the action of a Prolog procedure. The subprogram is linked to a predicate in a Prolog program, and a call to this predicate results in a call to the subprogram. Therefore, there is a correspondence between the arguments of the Prolog predicate and the arguments of the subprogram, and like any other Prolog procedure, the subprogram may fail or succeed and bind variables, but it may as well raise an exception.

We may particularly identify two types of external procedure. These are those which are resatisfiable upon backtracking, i.e. nondeterministic, which are regular, and those which are not resatisfiable, i.e. deterministic, which are simple.     From the Prolog level, all types of external predicates may be called exactly like Prolog predicates. However, on the implementation level, deterministic externals use a different calling convention than Prolog predicates and nondeterministic externals. As a consequence, certain dynamic redefinitions are restricted (as described below).

In principle, the external procedure can be written in any language which is able to produce a .o object file. In the current implementation of ECLiPSe , only C macros are provided for external procedure definition, and so all of the following assumes that the external procedure is written as a function in C.

Apart from this external interface there are two other possibilities to call a C function from Prolog:



next up previous index
Next: Mapping between C Up: External Language Interface Previous: External Language Interface



Micha Meier
Mon Mar 4 12:11:45 MET 1996