Source consulting does not stop upon the first syntax or
execution error. The end-user can instruct the interpreter to
consult a Prolog file. This is easily done by issuing a query with
the consult/1 predicate. The predicate receives a path. The
clauses in the corresponding file are asserted and the directives
When a syntax error or an execution error from a clause or
directive is encountered the consult predicate does not abort.
Syntax errors are displayed and the corresponding clause is not
asserted respectively the corresponding directive is not executed:
Error: Term missing.
'exception.p' at 1
The syntax error will be displayed together with its source
location and the stack trace. Execution errors related to the
assertion of clauses will also be shown with their source location
and the stack trace:
Error: Can't modify system, built-in or static predicate write / 1.
'exception.p' at 3
Not all problems related to the assertion of clauses are so fatal
as to prevent the interpreter from adding the clause to the
knowledge base. When the interpreter encounters such a minor
problem it issues a warning instead of an error:
Warning: Singleton variable(s) [Y], use anonymous variable(s) (_).
'exception.p' at 5
The special Prolog source name “user” is reserved for consulting
from the console. The source name can be used without further
specifications and it instructs the interpreter to read clauses
and directives directly from the console window. The consult from
console ends with an end-of-file (^D on Mac and Linux, ^Z on
member(X,[_|Y]) :- member(X,Y).
:- member(X, "ABC"), write(X), nl, fail; true.
The consult from the console does not abolish its previously consulted predicates. It can thus be used to add more and more predicates to the knowledge base. Predicates have to be manually reset by means of the system predicate abolish/1.