PLOGHELP LISTING           Jonathan Laventhol, Wednesday 28th March 1984
                                Revised by Kathryn Seifert  October 1986

Predicates for writing clauses in the database to output file.

    ?- listing.
    ?- listing(X).

Keywords: output, write, list, database


This predicate has two forms: one which takes no arguments, and one
which takes a single argument. The first form lists all the clauses in
the current program to the current output file.  The second form
lists all clauses with atom X as predicate.

You can use the second form of the predicate in two ways :

    ?- listing(foo).        /* lists foo of any arity */
    ?- listing(foo/2).      /* only with arity 2 */

If you need some special form of listing, you can use current_predicate/3.
(see PLOGHELP * CURRENT_PREDICATE).

Listing uses writeq/1 (see PLOGHELP * WRITEQ), so terms should be
readable by read/1 (see PLOGHELP * READ) if the operator declarations
are the same as when the term was written.  If you want to save some
predicate in a file in a textual form, you could use a predicate like
this:

    filepred(Name/Arity, File) :-
        telling(Old), tell(File),
        saveprec(Name),
        listing(Name/Arity),
        told, tell(Old).

    saveprec(Name) :-
        current_op(Prec, Fix, Name),
        writeq(:-(op(Prec, Fix, Name))), write('.'), nl,
        fail.
    saveprec(_).

If you want to save the state of the whole system, you should use save/1
or save/2 (See PLOGHELP * SAVE).

-- RELATED DOCUMENTATION ----------------------------------------------

PLOGHELP * DATABASE
 Overview of Prolog database operations

PLOGHELP * I_O
 Overview of input/output operations in Prolog
