library(addportray) makes the use of
portray/1 more convenient.
In DEC-10 Prolog and C Prolog, a program could contain clauses like
portray(X) :- should_be_handled_here(X), print_it_this_way
scattered through any number of files. In Quintus Prolog, this
does not work, because each file will wipe out every other file's
portray/1; in any case, a clause for
portray/1 in a
module will do nothing at all, because it is
user:portray/1 that you
DEC-10 Prolog and C Prolog had a similar problem in that if you reconsulted a
containing such clauses, you lost all the other clauses for
Now, in order to add a link to
portray/1 clauses to your program, you can
do the following:
:- use_module(library(addportray)). local_portray(X) :- should_be_handled_here(X), print_it_this_way(X). :- add_portray(local_portray).
To cancel such a link, you can call
Note that if you use this package, you should not define
any other way; otherwise, these links will be lost.
You can link to other user-defined predicates (such as
this way too. Suppose the other
predicate to be linked to is
:- add_linking_clause(Link, Pred, Arity).
ensures that there is a clause
Pred(X1,...,XArity) :- Link(X1,...,XArity).
user, where Link/Arity is called
in the module from which
add_linking_clause/3 is called, and
:- del_linking_clause(Link, Pred, Arity).
ensures that there is no such clause. For example, you can
add a case to
term_expansion/2 by adding the following directive to a
:- add_linking_clause(local_expander, term_expansion, 2).