11.3.156 portray/1   hook


:- multifile user:portray/1.


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





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, it is assumed to have written T. If it fails, 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 tail 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:


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 are treated as failures, except an error message is also printed.

See Also

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

Send feedback on this subject.