Introduction

Quintus Prolog provides tools making it possible to call Prolog predicates from foreign languages. This is useful for a number of reasons.

To take advantage of Quintus Prolog's ability to be called from foreign functions, you must first know how to do either of the following:

Currently, only functions written in C can call Prolog predicates directly; this restriction may be lifted in future releases of Quintus Prolog. However, other languages such as Pascal and FORTRAN can call Prolog by virtue of their ability to call C. foreign code!) calls Prolog. The FORTRAN and Pascal stuff will then help users call the C functions. It just wasn't making sense writing all of this in terms of generic "foreign languages", because I knew full well I'd have to eventually do something different for FORTRAN and Pascal. While this should be more clear for release 3, it may as a result require more rewriting in case we ever do make Prolog directly callable from FORTRAN and Pascal.}

The interface between C and Prolog supports direct exchange of Prolog's atomic data types (atoms, integers or database reference). The data is automatically converted between Prolog's internal representation and the internal representation of the foreign language. The interface also supports passing any Prolog term from C and returning any Prolog term to C.