Manual: Overview


Quintus Prolog Manual


(PREV) (NEXT)

I-1: Overview

The Foreign Language Interface is the protocol by which you can call functions written in other programming languages from Prolog (see Chapter I-3), and by which you can call Prolog predicates from C (see Chapter I-4).

In both cases you have to supply declarations in Prolog specifying the argument types of the function/predicate being called. This is necessary so that the Prolog system can automatically make the necessary transformations of data as they are passed between the languages. The declarations are compiled into special abstract machine instructions in order to minimize the cost of inter-language calls.

It is possible to specify that an argument is a Prolog term. In this case a foreign function receiving such a term sees it as a special kind of object called a QP_term_ref. A set of functions is provided which allow foreign functions to manipulate terms via these QP_term_refs. Term passing is described in section I-3-8 and section I-4-4-2. The functions for manipulating terms are described in Chapter M.

Some kinds of data are not best represented in Prolog. It is better to keep such data in foreign data structures and just pass pointers to these structures to Prolog. Given such pointers, Prolog arithmetic predicates such as is/2 and =:=/2 allow access to foreign data; see section G-8-3. Foreign data can also be modified directly from Prolog using assign/2 which is described in Chapter M.

Input/Output operations on Prolog streams can be performed in C. Functions, macros and variables for this purpose are summarized in section I-5-8. The I/O system has been designed to make it maximally customizable at the C level. The kinds of customization that you might want to do are to create a stream to read from or write to a UNIX socket, or to create a stream to read from an encrypted file. The C level of the I/O system is described in Chapter I-5.

A number of functions are defined to aid in embedding Prolog programs into other software systems. These functions all begin with the letters "QU" and they are defined in Chapter I-2. The source of these functions is provided with the system, and you may define your own versions to replace them. To do this you will need to link your routines with the development system to make your own customized version of the development system. How to do this is described in Part H.


Copyright (C) 1998 SICS
contact: product support sales information