- Reference manual
- The SWI-Prolog library
- library(aggregate): Aggregation operators on backtrackable predicates
- library(apply): Apply predicates on a list
- library(assoc): Association lists
- library(broadcast): Broadcast and receive event notifications
- library(charsio): I/O on Lists of Character Codes
- library(check): Consistency checking
- library(clpb): CLP(B): Constraint Logic Programming over Boolean Variables
- library(clpfd): CLP(FD): Constraint Logic Programming over Finite Domains
- library(clpqr): Constraint Logic Programming over Rationals and Reals
- library(csv): Process CSV (Comma-Separated Values) data
- library(debug): Print debug messages and test assertions
- library(error): Error generating support
- library(gensym): Generate unique identifiers
- library(iostream): Utilities to deal with streams
- library(lists): List Manipulation
- library(main): Provide entry point for scripts
- library(nb_set): Non-backtrackable set
- library(www_browser): Activating your Web-browser
- library(option): Option list processing
- library(optparse): command line parsing
- library(ordsets): Ordered set manipulation
- library(pairs): Operations on key-value lists
- library(persistency): Provide persistent dynamic predicates
- library(pio): Pure I/O
- library(predicate_options): Declare option-processing of predicates
- library(prolog_pack): A package manager for Prolog
- library(prolog_xref): Cross-reference data collection library
- library(quasi_quotations): Define Quasi Quotation syntax
- library(random): Random numbers
- library(readutil): Reading lines, streams and files
- library(record): Access named fields in a term
- library(registry): Manipulating the Windows registry
- library(simplex): Solve linear programming problems
- library(solution_sequences): Modify solution sequences
- library(tabling): Tabled execution (SLG)
- library(thread_pool): Resource bounded thread management
- library(ugraphs): Unweighted Graphs
- library(url): Analysing and constructing URL
- library(varnumbers): Utilities for numbered terms
- library(yall): Lambda expressions
- The SWI-Prolog library
- Reference manual
This library collects information on defined and used objects in Prolog source files. Typically these are predicates, but we expect the library to deal with other types of objects in the future. The library is a building block for tools doing dependency tracking in applications. Dependency tracking is useful to reveal the structure of an unknown program or detect missing components at compile time, but also for program transformation or minimising a program saved state by only saving the reachable objects.
This section gives a partial description of the library API, providing some insight in how you can use it for analysing your program. The library should be further modularized, moving its knowledge about, for example, XPCE into a different file and allowing for adding knowledge about other libraries such as Logtalk. Please do not consider this interface rock-solid.
The library is exploited by two graphical tools in the SWI-Prolog environment: the XPCE front-end started by gxref/0 and described in section 3.7, and PceEmacs (section 3.4), which exploits this library for its syntax colouring.
For all predicates described below, Source is the source that is processed. This is normally a filename in any notation acceptable to the file loading predicates (see load_files/2). Using the hooks defined in section A.27.1 it can be anything else that can be translated into a Prolog stream holding Prolog source text. Callable is a callable term (see callable/1). Callables do not carry a module qualifier unless the referred predicate is not in the module defined Source.
- Gather information on Source. If Source has already been processed and is still up-to-date according to the file timestamp, no action is taken. This predicate must be called on a file before information can be gathered.
- Source has been processed.
- Remove the information gathered for Source
- xref_defined(?Source, ?Callable, -How)
- Callable is defined in Source. How is
Declared dynamic at Line
Declared thread local at Line
Declared multifile at Line
First clause at Line
Foreign library loaded at Line
CHR Constraint at Line
Imported from File
- xref_called(?Source, ?Callable, ?By)
- Callable is called in Source by By.
- xref_exported(?Source, ?Callable)
- Callable is public (exported from the module).
- xref_module(?Source, ?Module)
- Source is a module file defining the given module.
- True if Callable is a built-in predicate. Currently this is
assumed for all predicates defined in the
systemmodule and having the property
built_in. Built-in predicates are not registered as `called'.
The library provides hooks for extending the rules it uses for finding predicates called by some programming construct.
- prolog:called_by(+Goal, -Called)
- Goal is a non-var subgoal appearing in the called object
(typically a clause body). If it succeeds it must return a list of goals
called by Goal. As a special construct, if a term Callable+N
is returned, N variable arguments are added to Callable
before further processing. For simple meta-calls a single fact suffices.
Complex rules as used in the
library(html_write)library provided by the HTTP package examine the arguments and create a list of called objects.
The current system cannot deal with the same name/arity in different modules that behave differently with respect to called arguments.