4.11.1.1 Referring to predicates from a message
Many messages refer to a predicate. Rather than formatting the
predicate indicator yourself, use the grammar rules below. They are
defined in the system module $messages and are declared
public, i.e., they must be called with an explicit module
qualification. Using them makes the reference consistent with the
messages of the system: the predicate indicator is written using the
code style class and, if the source location of the
predicate is known, it becomes a hyperlink to its definition on
terminals that support this (see section
2.5 and the Prolog flag
hyperlink_term).
This works for predicates defined in C as well, provided the system can
resolve the address of the implementing function.
prolog:message(no_such_predicate(PI)) -->
[ 'There is no ' ],
'$messages':predicate_reference(PI).
- predicate_reference(+Spec)
// - predicate_reference(+Spec,
+Options)
// - Emit a reference to a predicate. Spec is a (possibly module
qualified) head or predicate indicator. Non-terminals are printed using
the
//notation. Options:- module(Which)
- One of
auto(default),hideorshow. Usingauto, the module qualification is removed if it isuser,systemor a system internal module. - link(Bool)
- If
false, do not create a hyperlink. Default istrue. - style(Class)
- Style class for the reference. Default is
code. - tag(Bool)
- If
true, add a tag that indicates the kind of the predicate. Default isfalse. This is intended for messages that list candidate predicates, one per line.
- predicate_definition(+Spec,
+Message)
// - Emit “Message at File:Line” on a new line if the location of Spec is known and nothing at all if it is not.
- [semidet]predicate_kind(+Spec, -Kind)
- Classify a predicate as
iso,built_in,foreign,library(Name),module(Module),userorundefined. This is the classification used by thetag(true)option above. Fails if Spec does not denote a predicate.