Table of Contents
1 Introduction
1.1 SWI-Prolog
1.1.1 Other books about Prolog
1.2 Status
1.3 Compliance to the ISO standard
1.4 Should you be using SWI-Prolog?
1.5 The XPCE GUI system for Prolog
1.6 Release Notes
1.6.1 Version 1.8 Release Notes
1.6.2 Version 1.9 Release Notes
1.6.3 Version 2.0 Release Notes
1.6.4 Version 2.5 Release Notes
1.6.5 Version 2.6 Release Notes
1.6.6 Version 2.7 Release Notes
1.6.7 Version 2.8 Release Notes
1.6.8 Version 2.9 Release Notes
1.6.9 Version 3.0 Release Notes
1.6.10 Version 3.1 Release Notes
1.6.11 Version 3.3 Release Notes
1.6.11.1 Incompatible changes
1.6.12 Version 3.4 Release Notes
1.6.13 Version 4.0 Release Notes
1.7 Acknowledgements
2 Overview
2.1 Getting started quickly
2.1.1 Starting SWI-Prolog
2.1.1.1 Starting SWI-Prolog on Unix
2.1.1.2 Starting SWI-Prolog on Windows
2.1.2 Executing a query
2.2 The user's initialisation file
2.3 Initialisation files and goals
2.4 Command line options
2.5 GNU Emacs Interface
2.6 Online Help
2.7 Query Substitutions
2.7.1 Limitations of the History System
2.8 Reuse of toplevel bindings
2.9 Overview of the Debugger
2.10 Compilation
2.10.1 During program development
2.10.2 For running the result
2.10.2.1 Creating a shell-script
2.10.2.2 Creating a saved-state
2.10.2.3 Compilation using the -c commandline option
2.11 Environment Control (Prolog flags)
2.12 An overview of hook predicates
2.13 Automatic loading of libraries
2.14 Garbage Collection
2.15 Syntax Notes
2.15.1 ISO Syntax Support
2.15.1.1 Character Escape Syntax
2.15.1.2 Syntax for non-decimal numbers
2.16 System limits
2.16.1 Limits on memory areas
2.16.1.1 The heap
2.16.2 Other Limits
2.16.3 Reserved Names
3 Built-in predicates
3.1 Notation of Predicate Descriptions
3.2 Character representation
3.3 Loading Prolog source files
3.3.1 Quick load files
3.4 Listing and Editor Interface
3.5 Verify Type of a Term
3.6 Comparison and Unification or Terms
3.6.1 Standard Order of Terms
3.7 Control Predicates
3.8 Meta-Call Predicates
3.9 ISO compliant Exception handling
3.9.1 Debugging and exceptions
3.9.2 The exception term
3.9.3 Printing messages
3.10 Handling signals
3.10.1 Notes on signal handling
3.11 The `block' control-structure
3.12 DCG Grammar rules
3.13 Database
3.13.1 Update view
3.13.2 Indexing databases
3.14 Declaring predicates properties
3.15 Examining the program
3.16 Input and output
3.16.1 Input and output using implicit source and destination
3.16.2 Explicit Input and Output Streams
3.16.3 Switching Between Implicit and Explicit I/O
3.17 Status of streams
3.18 Primitive character I/O
3.19 Term reading and writing
3.20 Analysing and Constructing Terms
3.21 Analysing and constructing atoms
3.22 Classifying characters
3.23 Representing text in strings
3.24 Operators
3.25 Character Conversion
3.26 Arithmetic
3.27 Arithmetic Functions
3.28 Adding Arithmetic Functions
3.29 List Manipulation
3.30 Set Manipulation
3.31 Sorting Lists
3.32 Finding all Solutions to a Goal
3.33 Invoking Predicates on all Members of a List
3.34 Forall
3.35 Formatted Write
3.35.1 Writef
3.35.2 Format
3.35.3 Programming Format
3.36 Terminal Control
3.37 Operating System Interaction
3.38 File System Interaction
3.39 Multi-threading (alpha code)
3.39.1 Thread communication
3.39.2 Thread synchronisation
3.39.3 Thread-support library(threadutil)
3.39.4 Status of the thread implementation
3.40 User Toplevel Manipulation
3.41 Creating a Protocol of the User Interaction
3.42 Debugging and Tracing Programs
3.43 Obtaining Runtime Statistics
3.44 Finding Performance Bottlenecks
3.45 Memory Management
3.46 Windows DDE interface
3.46.1 DDE client interface
3.46.2 DDE server mode
3.47 Miscellaneous
4 Using Modules
4.1 Why Using Modules?
4.2 Name-based versus Predicate-based Modules
4.3 Defining a Module
4.4 Importing Predicates into a Module
4.4.1 Reserved Modules
4.5 Using the Module System
4.5.1 Object Oriented Programming
4.6 Meta-Predicates in Modules
4.6.1 Definition and Context Module
4.6.2 Overruling Module Boundaries
4.7 Dynamic Modules
4.8 Module Handling Predicates
4.9 Compatibility of the Module System
4.9.1 Emulating meta_predicate/1
5 Foreign Language Interface
5.1 Overview of the Interface
5.2 Linking Foreign Modules
5.2.1 What linking is provided?
5.2.2 What kind of loading should I be using?
5.3 Dynamic Linking of shared libraries
5.4 Using the library shlib for
.DLL
and
.so
files
5.4.1 Static Linking
5.5 Interface Data types
5.5.1 Type
term_t
: a reference to a Prolog term
5.5.1.1 Interaction with the garbage collector and stack-shifter
5.5.2 Other foreign interface types
5.6 The Foreign Include File
5.6.1 Argument Passing and Control
5.6.1.1 Non-deterministic Foreign Predicates
5.6.2 Atoms and functors
5.6.2.1 Atoms and atom-garbage collection
5.6.3 Analysing Terms via the Foreign Interface
5.6.3.1 Testing the type of a term
5.6.3.2 Reading data from a term
5.6.3.3 Exchanging text using length and string
5.6.3.4 Reading a list
5.6.3.5 An example: defining write/1 in C
5.6.4 Constructing Terms
5.6.5 Unifying data
5.6.6 Calling Prolog from C
5.6.6.1 Predicate references
5.6.6.2 Initiating a query from C
5.6.7 Discarding Data
5.6.8 Foreign Code and Modules
5.6.9 Prolog exceptions in foreign code
5.6.10 Foreign code and Prolog threads
5.6.11 Miscellaneous
5.6.11.1 Term Comparison
5.6.11.2 Recorded database
5.6.12 Catching Signals (Software Interrupts)
5.6.13 Errors and warnings
5.6.14 Environment Control from Foreign Code
5.6.15 Querying Prolog
5.6.16 Registering Foreign Predicates
5.6.17 Foreign Code Hooks
5.6.18 Storing foreign data
5.6.18.1 Examples for storing foreign data
5.6.19 Embedding SWI-Prolog in a C-program
5.7 Linking embedded applications using plld
5.7.1 A simple example
5.8 The Prolog `home' directory
5.9 Example of Using the Foreign Interface
5.10 Notes on Using Foreign Code
5.10.1 Memory Allocation
5.10.2 Debugging Foreign Code
5.10.3 Name Conflicts in C modules
5.10.4 Compatibility of the Foreign Interface
6 Generating Runtime Applications
6.1 Limitations of qsave_program
6.2 Runtimes and Foreign Code
6.3 Using program resources
6.3.1 Predicates Definitions
6.3.2 The
plrc
program
6.4 Finding Application files
6.4.1 Passing a path to the application
6.5 The Runtime Environment
6.5.1 The Runtime Emulator
A Hackers corner
A.1 Examining the Environment Stack
A.2 Intercepting the Tracer
A.3 Hooks using the
exception/3
predicate
A.4 Hooks for integrating libraries
A.5 Readline Interaction
B Glossary of Terms
C Summary
C.1 Predicates
C.2 Arithmetic Functions
C.3 Operators
D Bibliography