Table of Contents
1 Introduction
1.1 SWI-Prolog
1.2 Status
1.3 Should you be Using SWI-Prolog?
1.4 The XPCE GUI system for Prolog
1.5 Version 1.5 Release Notes
1.6 Version 1.6 Release Notes
1.7 Version 1.7 Release Notes
1.8 Version 1.8 Release Notes
1.9 Version 1.9 Release Notes
1.10 Version 2.0 Release Notes
1.11 Version 2.1 Release Notes
1.12 Version 2.5 Release Notes
1.13 Version 2.6 Release Notes
1.14 Version 2.7 Release Notes
1.15 Version 2.8 Release Notes
1.16 Version 2.9 Release Notes
1.17 Version 3.0 Release Notes
1.18 Version 3.1 Release Notes
1.19 Version 3.2 Release Notes
1.20 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 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
2.12 Automatic loading of libraries
2.13 Garbage Collection
2.14 Syntax Notes
2.14.1 ISO Syntax Support
2.14.1.1 Character Escape Syntax
2.14.1.2 Syntax for Non-Decimal Numbers
2.15 System Limits
2.15.1 Limits on Memory Areas
2.15.1.1 The heap
2.15.2 Other Limits
2.15.3 Reserved Names
3 Built-In Predicates
3.1 Notation of Predicate Descriptions
3.2 Consulting Prolog Source files
3.2.1 Quick Load Files
3.3 Listing and Editor Interface
3.4 Verify Type of a Term
3.5 Comparison and Unification or Terms
3.5.1 Standard Order of Terms
3.6 Control Predicates
3.7 Meta-Call Predicates
3.8 ISO compliant Exception handling
3.8.1 Debugging and exceptions
3.8.2 The exception term
3.8.3 Printing a message from an exception
3.9 Handling signals
3.9.1 Notes on signal handling
3.10 Advanced control-structures: blocks
3.11 Grammar rule interface (phrase)
3.12 Database
3.12.1 Indexing databases
3.13 Declaring Properties of Predicates
3.14 Examining the Program
3.15 Input and Output
3.15.1 Input and Output Using Implicit Source and Destination
3.15.2 Explicit Input and Output Streams
3.15.3 Switching Between Implicit and Explicit I/O
3.16 Status of Input and Output Streams
3.17 Primitive Character Input and Output
3.18 Term Reading and Writing
3.19 Analysing and Constructing Terms
3.20 Analysing and Constructing Atoms
3.21 Representing Text in Strings
3.22 Operators
3.23 Arithmetic
3.24 Arithmetic Functions
3.25 Adding Arithmetic Functions
3.26 List Manipulation
3.27 Set Manipulation
3.28 Sorting Lists
3.29 Finding all Solutions to a Goal
3.30 Invoking Predicates on all Members of a List
3.31 Forall
3.32 Formatted Write
3.32.1 Writef
3.32.2 Format
3.32.3 Programming Format
3.33 Terminal Control
3.34 Operating System Interaction
3.35 File System Interaction
3.36 Multi-threading (PRE-ALPHA: developers only!)
3.37 User Toplevel Manipulation
3.38 Creating a Protocol of the User Interaction
3.39 Debugging and Tracing Programs
3.40 Obtaining Runtime Statistics
3.41 Finding Performance Bottlenecks
3.42 Memory Management
3.43 Windows DDE interface
3.43.1 DDE client interface
3.43.2 DDE server mode
3.44 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.4.2 Dynamic Linking based on
load_foreign/[2,5]
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.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 Reading a list
5.6.3.4 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 Miscellaneous
5.6.10.1 Term Comparison
5.6.10.2 Recorded database
5.6.11 Catching Signals (Software Interrupts)
5.6.12 Errors and warnings
5.6.13 Environment Control from Foreign Code
5.6.14 Querying Prolog
5.6.15 Registering Foreign Predicates
5.6.16 Foreign Code Hooks
5.6.17 Storing foreign data
5.6.17.1 Examples for storing foreign data
5.6.18 Embedding SWI-Prolog in a C-program
5.7 Linking embedded applications using plld
5.7.1 A simple example
5.8 Example of Using the Foreign Interface
5.9 Notes on Using Foreign Code
5.9.1 Memory Allocation
5.9.2 Debugging Foreign Code
5.9.3 Name Conflicts in C modules
5.9.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 Exception Handling
A.4 Readline Interaction
B Summary
B.1 Predicates
B.2 Arithmetic Functions
B.3 Operators
C Bibliography