Download SICStus Prolog User`s Manual

Transcript
994
SICStus Prolog
11.3.91 generate_message/3
Synopsis
[extendible]
:- multifile ’SU_messages’:generate_message/3.
’SU_messages’:generate_message(+MessageTerm, -S0, -S )
For a given MessageTerm, generates a list composed of Control-Arg pairs and the atom nl.
This can be translated into a nested list of Control-Arg pairs, which can be used as input
to print_message_lines/3.
Arguments
MessageTerm
term
May be any term.
S0
list of pair
The resulting list of Control-Args pairs.
S
list of pair
The remaining list.
Description
Clauses for ’SU_messages’:generate_message/3 underly all messages from Prolog. They
may be examined and altered. They are found in library(’SU_messages’).
The purpose of this predicate is to allow you to redefine the displayal of Prolog’s messages.
For example, to translate all the messages from English into some other language.
This predicate should not be modified if all you want to do is modify or add a few messages:
user:generate_message_hook/3 is provided for that purpose.
The Prolog system uses the built-in predicate print_message/2 to print all its messages.
When print_message/2 is called, it calls user:generate_message_hook(Message,L,[])
to generate the message. If that fails, ’SU_messages’:generate_message(Message,L,[])
is called instead. If that succeeds, L is assumed to have been bound to a list whose elements
are either Control-Args pairs or the atom nl. Each Control-Arg pair should be such that
the call
format(user_error, Control, Args )
is valid. The atom nl is used for breaking the message into lines. Using the format
specification ‘~n’ (new-line) is discouraged, since the routine that actually prints the message
(see user:message_hook/3 and print_message_lines/3) may need to have control over
newlines.
’SU_messages’:generate_message/3 is not included by default in runtime systems, since
end-users of application programs should probably not be seeing any messages from the
Prolog system.