When referring to keyboard characters, printing characters are written thus: a, while control characters are written like this: ^A. Thus ^C is the character you get by holding down the CTL key while you type c. Finally, the special control characters carriage-return, line-feed and space are often abbreviated to RET, LFD and SPC respectively.
When introducing a built-in predicate, we shall present its usage with a mode spec which has the form name(arg, ..., arg) where each arg denotes how that argument should be instantiated in goals, and has one of the following forms:
Mode specs are not only used in the manual, but are part of the syntax of the language as well. When used in the source code, however, the ArgName part must be omitted. That is, arg must be either :, +, -, or ?.
In the context of certain compiler declarations, we shall need the
following notation: Predicates in Prolog are distinguished by their name
and their arity. The notation name/arity
is
therefore used when it is necessary to refer to a predicate
unambiguously; e.g. concatenate/3
specifies the predicate which
is named "concatenate" and which takes 3 arguments. In general, a
predicate spec takes the form name/arity
. With
the introduction of the module system, this spec is only defined
relative to the "current" module. An absolute predicate spec must
include a module prefix: module:name/arity
.
The full Prolog system with top-level, compiler, debugger etc. is known as the Development System. On some platforms, both a sequential and an OR-parallel Development System can be built. The OR-parallel Development System is also known as Muse.
OR-parallelism executes clauses and disjunctions of a predicate in parallel and is useful for search and all-solutions style programming. No change or annotations of the programs are necessary but sometimes more parallelism may be utilized if the program is modified. The main issue is to avoid side effects that might serialize the search. Except for some few exceptions Muse preserves the full functionality of SICStus Prolog. Muse is still an experimental system and is not formally supported.
It is possible to link user-written C code with a subset of SICStus Prolog to create stand-alone applications, called Runtime Systems. Only sequential Runtime Systems are available. When introducing a built-in predicate, any limitations on its use in Runtime Systems will be mentioned.
Whenever this manual documents a C function as part of SICStus Prolog's foreign language interface, the function prototype will be displayed in ANSI C syntax.
SICStus Prolog complies in spirit, if not in detail, with the Draft International Standard ISO/IEC 13211-1 (PROLOG: Part 1--General Core). In particular, SICStus Prolog does not offer a strictly conforming mode which rejects uses of implementation specific features. Minor deviations also concern e.g. the syntax, the arithmetic functions, and the error system.
To aid programmers who wish to write standard compliant programs, built-in predicates that have a counterpart in the ISO Prolog Standard are annotated with [ISO] in this manual, where appropriate with a comment clarifying the difference between the SICStus and the prescribed ISO Prolog versions.
This section summarizes the changes in release 3 wrt. previous SICStus Prolog releases as well as changes introduced by patch releases.
call_residue/2
has been modified so that
goals that are disjunctively blocked on several variables are returned
correctly in the second argument. See section Coroutining.
setarg/3
has been removed. Its
functionality is provided by the new built-ins create_mutable/2
,
get_mutable/2
, and update_mutable/2
, which implement a
timestamp technique for value-trailing with low-level
support. See section Modification of Terms.
unix/1
and plsys/1
have been
removed. Their functionality is provided by
prolog_flag(argv,X)
, by the new halt/1
built-in, and
by the new library(system)
module which also contains several new
predicates. See section Operating System Utilities.
library(sockets)
module. See section Socket I/O.
time_out/3
has been moved to the new
library(timeout)
module. See section Timeout Predicate.
term_hash/(2,4)
, subsumes_chk/2
, and
term_subsumer/3
have been moved to the new library(terms)
module, which also contains operations for unification with occurs-check,
testing acyclicity, and getting the variables of a term.
See section Term Utilities.
+chars
, -chars
and [-chars]
for fast conversion between
C strings and Prolog lists of character codes. Several new interface functions
are available. See section Calling C from Prolog.
SP_term_ref
,
making the functions SP_show_term()
and SP_hide_term()
obsolete.
See section Calling Prolog from C.
library(gmlib)
has been replaced by
the Tcl/Tk based library(tcltk)
. A version of library(gmlib)
converted to SICStus Prolog release 3 is available from
`ftp://ftp.sics.se/archive/sicstus3/gmlib.tar.gz'. See section Tcl/Tk Interface.
library(objects)
module has been enhanced. See section Prolog Objects.
self
.
Prolog goals in methods must be prefixed by :.
library(charsio)
, the open_chars_stream/(3-4)
predicates
have been replaced by open_chars_stream/2
and
with_output_to_chars/(2-3)
. See section I/O on Lists of Character Codes.
library(assoc)
module now implements AVL trees instead of
unbalanced binary trees. See section Association Lists.
library(atts)
implements
attributed variables, a general mechanism for associating logical variables
with arbitrary attributes. Comes with a number of hooks that make it
convenient to define and interface to constraint solvers.
See section Attributed Variables.
library(clpb)
and is implemented on top of library(atts)
. See section Boolean Constraint Solver.
library(clpq)
) and reals
(library(clpr)
), implemented on top of library(atts)
.
See section Constraint Logic Programming over Rationals or Reals.
user:goal_expansion/3
is a new hook predicate for macro-expansion.
See section Term and Goal Expansion.
bb_put/2
, bb_get/2
, bb_delete/2
, and bb_update/3
are new built-ins implementing blackboard primitives.
See section Blackboard Primitives.
prolog_load_context/2
(see section Information about the State of the Program) is a new built-in predicate
for accessing aspects of the context of files being loaded.
file_search_path/2
(see section Stream I/O) is a new hook predicate
providing an alias expansion mechanism for filenames.
gcd/2
is a new built-in function. See section Arithmetic.
walltime
measures elapsed absolute time.
See section Information about the State of the Program.
ensure_loaded/1
and use_module/(1-3)
do not always reload files.
Changes introduced in patchlevel 4:
SP_foreign_reinit_hook
is not supported, (see section Hooks).
library(sockets): socket_select/5
arg 1 may be a, possibly empty,
list of passive sockets, arg 3 returns a, possibly empty, list of new
streams.
library(system)
: The following new predicates are provided:
tmpnam/1
, directory_files/2
, file_property/2
,
delete_file/2
, make_directory/1
.
library(clpfd)
),
implemented on top of library(atts)
. See section Constraint Logic Programming over Finite Domains.
Changes introduced in patchlevel 5:
open/4
, enables opening files in binary mode.
library(charsio)
: New predicate with_output_to_chars/4
.
library(heaps)
: New predicates delete_from_heap/4
, empty_heap/1
, is_heap/1
.
library(queues)
: New predicate is_queue/1
.
library(sockets)
: New predicates: socket_accept/3
, and
socket_select/6
provide address of connecting
client. hostname_address/2
resolves name/ip-number.
SP_atom_length
returns the print name length of a Prolog atom.
Changes introduced in patchlevel 6:
library(clpfd)
)
has been enhanced by a programming interface for global constraints,
improved compilation to library constraints and other performance
enhancements, and by a number of new exported constraints. See section Constraint Logic Programming over Finite Domains.
library(objects)
: New hook predicate user:method_expansion/3
.
library(sockets)
: socket_select/5
has extended functionality.