end_of_file.
can be entered to return from the break
environment. If the -t toplevel command line
option is given, this goal is started instead of entering the default
interactive top level (prolog/0).
Notably the gui based versions (swipl-win on Windows and MacOS) provide the menu Run/New thread that opens a new toplevel that runs concurrently with the initial toplevel. The concurrent toplevel can be used to examine the program, in particular global dynamic predicates. It can not access global variables or thread-local dynamic predicates (see thread_local/1) of the main thread.
Aborting is implemented by throwing the reserved exception
'$aborted'
. This exception can be caught using catch/3,
but the recovery goal is wrapped with a predicate that prunes the choice
points of the recovery goal (i.e., as once/1)
and re-throws the exception. This is illustrated in the example below,
where we press control-C and‘a'. See also section
4.10.1.
?- catch((repeat,fail), E, true). ^CAction (h for help) ? abort % Execution Aborted
status
and there have been errors or warnings.
halt/1
has been extended in SWI-Prolog to accept the arg abort
.
This performs as halt/1
above except that:
In addition to an integer status name we also allow passing a
signal name. This is similar to abort
, blocking
halt cancellation and set the termination code to 128+signum. For
example, using halt(term)
the system exits with status 143
(= 128+15) on Linux.
user_input
. See also the Prolog flag
history. The prolog/0
predicate is terminated (succeeds) by typing the end-of-file character
(typically control-D).The following two hooks allow for expanding queries and handling the result of a query. These hooks are used by the top level variable expansion mechanism described in section 2.9.
user
, normally not defined. Query
and
Bindings represents the query read from the user and the
names of the free variables as obtained using read_term/3.
If this predicate succeeds, it should bind Expanded and ExpandedBindings
to the query and bindings to be executed by the top level. This
predicate is used by the top level (prolog/0).
See also expand_answer/2
and
term_expansion/2.user
, normally not defined. Expand the
result of a successfully executed top-level query. Bindings
is the query
<Name>=<Value> binding list
from the query. ExpandedBindings must be unified with the
bindings the top level should print.