next up previous
Next: Discarding Data Up: The Foreign Include Previous: When is locking

Calling Prolog from C

The Prolog system can be called back from C. This is done by constructing a term with the functions described above and then calling PL_call(). PL_call() executes the goal and returns TRUE or FALSE depending on success or failure of the called predicate. There are no means to backtrack over the Prolog predicate. If alternatives are wanted call findall/3 and read the result from the third argument.

int
PL_call( term_t, module_t)
  Call term just like the Prolog predicate once/1. Term is called in the specified module, or in the context module if module_t = NULL. Returns TRUE if the call succeeds, FALSE otherwise. Figure gif shows an example to obtain the number of defined atoms. All checks are omitted to improve readability.



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