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) :-

scattered through any number of files. In Quintus Prolog, this does not work, because each file will wipe out every other file's clauses for 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 must define. DEC-10 Prolog and C Prolog had a similar problem in that if you reconsulted a file containing such clauses, you lost all the other clauses for portray/1.

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) :-
     :- add_portray(local_portray).

To cancel such a link, you can call

     :- del_portray(local_portray).

Note that if you use this package, you should not define portray/1 in any other way; otherwise, these links will be lost.

You can link to other user-defined predicates (such as term_expansion/2) this way too. Suppose the other predicate to be linked to is user:Pred/Arity. Then

     :- add_linking_clause(Link, Pred, Arity).

ensures that there is a clause

     Pred(X1,...,XArity) :- Link(X1,...,XArity).

in module 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 module:

     :- add_linking_clause(local_expander, term_expansion, 2).