#include <quintus/quintus.h> QP_pred_ref QP_predicate(name_string, arity, module_string) char *name_string; int arity; char *module_string;
Before a Prolog predicate can be called from a
foreign language it must be looked up. The C functions
QP_pred() perform this function. The lookup
step could have been folded into the functions that make the query,
but if a predicate was to be called many times the redundant, if
hidden, predicate lookup would be a source of unnecessary overhead.
QP_pred() can be called just once per
predicate. The result can then be stored in a variable and used as
QP_pred() return a
represents a Prolog predicate.
QP_predicate() is the most convenient way of looking up a
callable Prolog predicate. It is simply passed the name and module
of the predicate to be called as strings, the arity as an integer, and
QP_pred_ref(), which is used to make the actual call to Prolog.
QP_predicate() can only be used to look up predicates that
have been declared callable from foreign code. If some other predicate,
or a predicate that does not exist, is looked up,
is returned. This protects you from attempting to call a predicate that
isn't yet ready to be called.