library(prolog_xref)
implements‘offline'
cross-referencing library(prolog_codewalk)
implements‘online'
analysisThis library provides some consistency checks for the loaded Prolog program. The predicate make/0 runs list_undefined/0 to find undefined predicates in‘user' modules.
The checker can be expanded or restricted by modifying the dynamic multifile hook checker/2.
The checker may be used in batch, e.g., for CI workflows by calling
SWI-Prolog as below. Note that by using -l
to load the
program, the program is not started if it used initialization/2
of type
main
to start the program.
swipl -q --on-warning=status --on-error=status \ -g check -t halt -l myprogram.pl
[user]
. For example, to include the libraries into the
examination, use [user,library]
.user
as well as in a normal module; that is, predicates for which the local
definition overrules the global default definition.[user]
. For example, to include the libraries into the
examination, use [user,library]
.double_quotes
from codes
to string
,
creating packed string objects. Warnings may be suppressed using the
following multifile hooks:
double_quotes
.rational_syntax
to natural
, creating rational
numbers from
<integer>/<nonneg>. Options:
true
(default false
) also warn on rationals
appearing in arithmetic expressions.prefer_rationals
.format("Hello world~n")
is considered proper
use of string constants.my_checks
module defines a predicate list_format_mistakes/0:
:- multifile check:checker/2. check:checker(my_checks:list_format_mistakes, "errors with format/2 arguments").
The predicate is dynamic, so you can disable checks with retract/1. For example, to stop reporting redefined predicates:
retract(check:checker(list_redefined,_)).