Message printing primitives

Author(s): Daniel Cabeza, Edison Mera (improvements).

This module provides predicates for printing in a unified way informational messages, and also for printing some terms in a specific way.

Usage and interface

Documentation on exports

PREDICATE

Usage: message(Type,Message)

  • Description: Output to standard error Message, which is of type Type. The quiet prolog flag (see Changing system behaviour and various flags) controls which messages are actually output, depending on its type. Also, for error, warning and note messages, a prefix is output which denotes the severity of the message.
  • The following properties should hold at call time:
    (io_aux:message_type/1)Specifies the different types of messages.
    (io_aux:message_text/1)Message is an item or a list of items from this list:

    $$(String)
    String is a string, which is output with display_string/1.

    ”(Term)
    Term is output quoted. If the module write is loaded, the term is output with writeq/1, else with displayq/1.

    ~~(Term)
    Term is output unquoted. If the module write is loaded, the term is output with write/1, else with display/1.

    [](Term)
    Term is recursively output as a message, can be an item or a list of items from this list.

    Term
    Any other term is output with display/1.

PREDICATE

Usage: message_lns(Type,L0,L1,Message)

  • Description: Output to standard error Message, which is of type Type, and occurs between lines L0 and L1. This is the same as message/2, but printing the lines where the message occurs in a unified way (this is useful because automatic tools such as the emacs mode know how to parse them).
  • The following properties should hold at call time:
    (io_aux:message_type/1)Specifies the different types of messages.
    (basic_props:nnegint/1)L0 is a non-negative integer.
    (basic_props:nnegint/1)L1 is a non-negative integer.
    (io_aux:message_text/1)Message is an item or a list of items from this list:

    $$(String)
    String is a string, which is output with display_string/1.

    ”(Term)
    Term is output quoted. If the module write is loaded, the term is output with writeq/1, else with displayq/1.

    ~~(Term)
    Term is output unquoted. If the module write is loaded, the term is output with write/1, else with display/1.

    [](Term)
    Term is recursively output as a message, can be an item or a list of items from this list.

    Term
    Any other term is output with display/1.

PREDICATE

Usage: messages(Messages)

  • Description: Print each element in Messages using message/2, message_lns/4, message/1, error/1, warning/1, note/1 or debug/1 predicate. If the element should be printed using message_lns/4, it is printed in a compact way, avoiding to print the same file name several times.
  • The following properties should hold at call time:
    (basic_props:list/2)Messages is a list of message_infos.

PREDICATE
Defined as
error(Message) :-
        message(error,Message).
.

PREDICATE
Defined as
warning(Message) :-
        message(warning,Message).
.

PREDICATE
Defined as
note(Message) :-
        message(note,Message).
.

PREDICATE
Defined as
message(Message) :-
        message(message,Message).
.

PREDICATE
Defined as
debug(Message) :-
        message(debug,Message).
.

PREDICATE
inform_user(Message)

Similar to message/1, but Message is output with display_list/1. This predicate is obsolete, and may disappear in future versions.

PREDICATE
display_string(String)

Output String as the sequence of characters it represents.

Usage: display_string(String)

  • The following properties should hold at call time:
    (basic_props:string/1)String is a string (a list of character codes).

PREDICATE
display_list(List)

Outputs List. If List is a list, do display/1 on each of its elements, else do display/1 on List.

PREDICATE
display_term(Term)

Output Term in a way that a read/1 will be able to read it back, even if operators change.

REGTYPE

Usage:

  • Description: The type of the elements to be printed using the messages/1 predicate. Defined as
    message_info(message_lns(Source,Ln0,Ln1,Type,Text)) :-
            atm(Source),
            nnegint(Ln0),
            nnegint(Ln1),
            message_type(Type),
            message_text(Text).
    message_info(message(Type,Text)) :-
            atm(Type),
            message_text(Text).
    message_info(error(Text)) :-
            message_text(Text).
    message_info(warning(Text)) :-
            message_text(Text).
    message_info(note(Text)) :-
            message_text(Text).
    message_info(message(Text)) :-
            message_text(Text).
    message_info(debug(Text)) :-
            message_text(Text).
    
    .

REGTYPE

Usage:

  • Description: Specifies the different types of messages.

PREDICATE
No further documentation available for this predicate.

Known bugs and planned improvements

  • Run-time checks have been reported not to work with this code. That means that either the assertions here, or the code that implements the run-time checks are erroneous.
  • message/2 assumes that a module with name 'write' is library(write).