11.3.156 portray/1   hook

Synopsis

:- multifile user:portray/1.

user:portray(+Term)

A way for the user to over-ride the default behavior of print/1.

Arguments

Term

term

Description

If user:portray/1 is defined, then the predicates listed below performing term output will call it on the term itself and on every non-variable subterm T. If user:portray/1 succeeds, then it is assumed to have written T. If it fails, then the calling predicate will write the principal functor of T and treat the arguments of T recursively.

Note that on lists ([_|_]), user:portray/1 will be called on the whole list to user:portray/1 and, if that call fails, on each list element, but not on every suffix of the list.

Note that a variable written from within user:portray/1 may be written with a different name than that used by the surrounding write predicate.

The affected predicates are:

print/[1,2]
write_term/[2,3]

when used with the option portrayed(true)

goals during debugging

controlled by the debugger_print_options Prolog flag, whose value by default includes portrayed(true)

top-level variable bindings

controlled by the toplevel_print_options Prolog flag, whose value by default includes portrayed(true)

Exceptions

Exceptions are treated as failures, except an error message is also printed.

See Also

ref-iou-tou, ref-lps-flg.


Send feedback on this subject.