next up previous contents index
Next: Creating a Protocol of Up: Built-in predicates Previous: Status of the thread   Contents   Index

User Toplevel Manipulation

break0 Recursively start a new Prolog top level. This Prolog top level has its own stacks, but shares the heap with all break environments and the top level. Debugging is switched off on entering a break and restored on leaving one. The break environment is terminated by typing the system's end-of-file character (control-D). If the -ttoplevel command line option is given this goal is started instead of entering the default interactive top level (prolog0). abort0 Abort the Prolog execution and restart the top level. If the -ttoplevel command line options is given this goal is started instead of entering the default interactive top level.

There are two implementations of abort0. The default one uses the exception mechanism (see throw1), throwing the exception $aborted. The other one uses the C-construct longjmp() to discard the entire environment and rebuild a new one. Using exceptions allows for proper recovery of predicates exploiting exceptions. Rebuilding the environment is safer if the Prolog stacks are corrupt. Therefore the system will use the rebuild-strategy if the abort was generated by an internal consistency check and the exception mechanism otherwise. Prolog can be forced to use the rebuild-strategy setting the prolog flag abort_with_exception to false.

halt0 Terminate Prolog execution. Open files are closed and if the command line option -tty is not active the terminal status (see Unix stty(1)) is restored. Hooks may be registered both in Prolog and in foreign code. Prolog hooks are registered using at_halt1. halt0 is equivalent to halt(0). halt1+Status Terminate Prolog execution with given status. Status is an integer. See also halt0. prolog0 This goal starts the default interactive top level. Queries are read from the stream user_input. See also the history prolog_flag (current_prolog_flag2). The prolog0 predicate is terminated (succeeds) by typing the end-of-file character (On most systems control-D).

The following two hooks allow for expanding queries and handling the result of a query. These hooks are used by the toplevel variable expansion mechanism described in topvars.

expand_query4+Query, -Expanded, +Bindings, -ExpandedBindings Hook in module 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_term3. If this predicate succeeds, it should bind Expanded and ExpandedBindings to the query and bindings to be executed by the toplevel. This predicate is used by the toplevel (prolog0). See also expand_answer2 and term_expansion2.

expand_answer2+Bindings, -ExpandedBindings Hook in module user, normally not defined. Expand the result of a successfully executed toplevel query. Bindings is the query $\bnfmeta{Name}=\bnfmeta{Value}$ binding list from the query. ExpandedBindings must be unified with the bindings the toplevel should print.


next up previous contents index
Next: Creating a Protocol of Up: Built-in predicates Previous: Status of the thread   Contents   Index
Dr. Richard Botting 2001-12-12