PLOGHELP DIRECTIVES                              Robert Duncan, May 1987
                                                       Revised July 1993

Directives and queries to the Prolog compiler.

The predicates

    :-/1 and ?-/1

introduce directives and queries to the Prolog compiler. Both of these
predicates are declared by default as prefix operators with type 'fx'
and precedence 255. (For a discussion of operators see PLOGHELP * OP).

When Prolog compiles a file, the treatment of terms read from the file
normally differs depending on the current compilation mode (described in
PLOGHELP * COMPILE). Directives and queries, however, are special: in
all compilation modes, when a directive or query is read from a file,
its argument is executed immediately as a goal. For example, the
directive:

    :- format("Compilation started ...~n").

inserted into a Prolog program file would cause a message to be printed
whenever the file was compiled.

The behaviour of directives and queries differs in the amount of output
produced when the argument goal is executed. The argument to a directive
is executed silently: no output is produced unless the goal fails in
which case a warning message is printed. This takes the form of a
question mark, '? ', followed by the failed goal. The argument to a
query is executed by the interactive system, and produces exactly the
same output as if the goal had been typed in response to a '?- ' prompt.
Thus all variable bindings are reported and a 'yes'/'no' message is
printed on completion.

Loading a file from inside Ved (using LMR for example -- see HELP * LMR)
is the same as reconsulting the file, so directives provide a quick way
of executing goals from inside the editor. As an example, try marking
and loading this line:

    ?- X = 1; X = 2.

Because directives and queries are processed identically in all
compilation modes, a file consisting only of directives and queries can
be compiled in any mode. There are even similar facilities available
from Pop-11: when the Prolog subsystem is loaded, the words ":-" and
"?-" are declared as syntax words which read and execute Prolog goals
(see PLOGHELP * POPTOPLOG).


--- C.all/plog/help/directives
--- Copyright University of Sussex 1993. All rights reserved.
