8.17 Miscellaneous

?X = ?Y ISO
Defined as if by the clause Z=Z.; i.e. X and Y are unified.
?X \= ?Y ISO

The same as \+ X = Y; i.e. X and Y are not unifiable.

unify_with_occurs_check(?X, ?Y) ISO
True if X and Y unify to a finite (acyclic) term. Runs in almost linear time.
length(?List,?Length)
If List is instantiated to a list of determinate length, then Length will be unified with this length.

If List is of indeterminate length and Length is instantiated to an integer, then List will be unified with a list of length Length. The list elements are unique variables.

If Length is unbound then Length will be unified with all possible lengths of List.

numbervars(?Term,+N,?M) meta-logical
Unifies each of the variables in Term with a special term, so that write(Term) (or writeq(Term)) (see Term I/O) prints those variables as (`A' + (i mod 26))(i/26) where i ranges from N to M-1. N must be instantiated to an integer. If it is 0 you get the variable names A, B, ..., Z, A1, B1, etc. This predicate is used by listing/[0,1] (see State Info).
undo(:Goal)
The goal Goal is executed on backtracking. This predicate is useful if Goal performs some side-effect, which must be done on backtracking to undo another side-effect.

Note that this operation is immune to cuts. That is, undo/1 does not behave as if it were defined by:

          weak_undo(_).
          weak_undo(Goal) :- Goal, fail.
     

since defining it that way would not guarantee that Goal be executed on backtracking.

Note also that the Prolog top-level operates as a read-call-fail loop, and backtracks implicitly for each new query. Raised exceptions and the predicates halt/0 and abort/0 cause implicit backtracking as well.

halt ISO
Causes Prolog to exit back to the shell. (In recursive calls to Prolog from C, this predicate will return back to C instead.)
halt(+Code) ISO
Causes the Prolog process to immediately exit back to the shell with the integer return code Code, even if it occurs in a recursive call from C.
op(+Precedence,+Type,+Name) ISO
Declares the atom Name to be an operator of the stated Type and Precedence (see Operators). Name may also be a list of atoms in which case all of them are declared to be operators. If Precedence is 0 then the operator properties of Name (if any) are cancelled.
current_op(?Precedence,?Type,?Op) ISO
The atom Op is currently an operator of type Type and precedence Precedence. Neither Op nor the other arguments need be instantiated at the time of the call; i.e. this predicate can be used to generate as well as to test.
break development
Invokes a recursive top-level. See Nested.
abort
Aborts the current execution. See Nested. (In recursive calls to Prolog from C, this predicate will return back to C instead.)
save_files(+SourceFiles, +FileSpec)
Any module declarations, predicates, multifile clauses, or directives encountered in SourceFiles are saved in object format into the file denoted by FileSpec. Source file information as provided by source_file/[1,2] for the relevant predicates and modules is also saved.

If FileSpec does not have an explicit suffix, the suffix `.po' will be appended to it. SourceFiles should denote a single file or a list of files. FileSpec can later be loaded by load_files/[1,2], at which time any saved directives will be re-executed. If any of the SourceFiles declares a module, FileSpec too will behave as a module-file and export the predicates listed in the first module declaration encountered in SourceFiles. See Saving.

save_modules(+Modules, +FileSpec)
The module declarations, predicates, multifile clauses and initializations belonging to Modules are saved in object format into the file denoted by FileSpec. Source file information and embedded directives (except initializations) are not saved.

If FileSpec does not have an explicit suffix, the suffix `.po' will be appended to it. Modules should denote a single module or a list of modules. FileSpec can later be loaded by load_files/[1,2] and will behave as a module-file and export any predicates exported by the first module in Modules. See Saving.

save_predicates(:Spec, +FileSpec)
The predicates specified by the generalized predicate spec Spec are saved in object format into the file denoted by FileSpec. Source file information and embedded directives are not saved. Thus, this predicate is intended for saving data represented as tables of dynamic facts, not for saving static code.

If FileSpec does not have an explicit suffix, the suffix `.po' will be appended to it. FileSpec can later be loaded by load_files/[1,2]. See Saving.

save_program(+FileSpec)
save_program(+FileSpec, :Goal)
The system saves the program state into the file denoted by FileSpec. If FileSpec does not have an explicit suffix, the suffix `.sav' will be appended to it. When the program state is restored, Goal is executed. Goal defaults to true. See Saving.
restore(+FileSpec)
The system is returned to the program state previously saved to the file denoted by FileSpec with start-up goal Goal. restore/1 may succeed, fail or raise an exception depending on Goal. See Saving.
garbage_collect
Performs a garbage collection of the global stack immediately.
garbage_collect_atoms
Performs a garbage collection of the atoms immediately.
gc obsolescent
Enables garbage collection of the global stack (the default).
nogc obsolescent
Disables garbage collection of the global stack.
prompt(?Old,?New)
The sequence of characters (prompt) that indicates that the system is waiting for user input is represented as an atom, and unified with Old; the atom bound to New specifies the new prompt. In particular, the goal prompt(X, X) unifies the current prompt with X, without changing it. Note that this predicate only affects the prompt given when a user's program is trying to read from the standard input stream (e.g. by calling read/1). Note also that the prompt is reset to the default `|: ' on return to top-level.
version development,obsolescent
Displays the introductory messages for all the component parts of the current system.

Prolog will display its own introductory message upon startup by calling version/0. If this message is required at some other time it can be obtained using this predicate, which displays a list of introductory messages; initially this list comprises only one message (Prolog's), but you can add more messages using version/1.

version(+Message) development,obsolescent
Appends Message to the end of the message list that is output by version/0. Message must be an atom.

The idea of this message list is that, as systems are constructed on top of other systems, each can add its own identification to the message list. Thus version/0 should always indicate which modules make up a particular package. It is not possible to remove messages from the list.

help hookable,development,obsolescent
Displays basic information, or a user defined help message. It first calls user:user_help/0, and only if that call fails is a default help message printed on the current output stream.
user_help hook,obsolescent
user:user_help
This may be defined by the user to print a help message on the current output stream.