11
Interfacing Prolog and C
Calling C from Prolog
Introduction
foreign/2
directive
The C function
Input arguments
Output arguments
Input/output arguments
Writing non-deterministic C code
Example: input and output arguments
Example: non-deterministic code
Example: input/output arguments
Manipulating Prolog terms
Introduction
Managing Prolog atoms
Reading Prolog terms
Unifying Prolog terms
Creating Prolog terms
Testing the type of Prolog terms
Comparing Prolog terms
Copying Prolog terms
Comparing and evaluating arithmetic expressions
Raising Prolog errors
Managing the error context
Instantiation error
Type error
Domain error
Existence error
Permission error
Representation error
Evaluation error
Resource error
Syntax error
System error
Calling Prolog from C
Introduction
Example:
my_call/1
- a
call/1
clone
Example: recovering the list of all operators
Defining a new C
main()
function
Example: asking for ancestors
Copyright (C) 1999-2002 Daniel Diaz.
Chapters 9 and 10 : Copyright (C) 2002-2003 INRIA, Rémy Haemmerlé.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
More about the copyright