Author(s): The CLIP Group.
Version: 1.11#222 (2004/5/24, 13:8:7 CEST)
Version of last change: 1.11#214 (2004/3/26, 19:41:58 CET)
This module includes predicates related to exceptions, which alter the normal flow of Prolog.
exceptions
)exceptions
)
catch(Goal, Error, Handler)
Executes Goal
. If an exception is raised during its execution, Error
is unified with the exception, and if the unification succeeds, the entire execution derived from Goal
is aborted, and Handler
is executed. The execution resumes with the continuation of the catch/3 call. For example, given the code
p(X) :- throw(error), display('---'). p(X) :- display(X).
the execution of "catch(p(0), E, display(E)), display(.), fail.
" results in the output "error.
".
Meta-predicate with arguments: catch(goal,?,goal)
.
Usage: * ISO *
Error
is any term.
(basic_props:term/1
)
Goal
is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1
)
Handler
is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1
)
Error
is any term.
(basic_props:term/1
)
basic_props:native/1
)
intercept(Goal, Error, Handler)
Executes Goal
. If an exception is raised during its execution, Error
is unified with the exception, and if the unification succeeds, Handler
is executed and then the execution resumes after the predicate which produced the exception. Note the difference with builtin
catch/3
, given the same code defined there, the execution of "intercept(p(0), E, display(E)), display(.), fail.
" results in the output "error---.0.
".
Meta-predicate with arguments: intercept(goal,?,goal)
.
Usage:
Error
is any term.
(basic_props:term/1
)
Goal
is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1
)
Handler
is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1
)
Error
is any term.
(basic_props:term/1
)
throw(Ball)
Raises an error, throwing the exception Ball
, to be caught by an ancestor
catch/3
or
intercept/3
. The closest matching ancestor is chosen. Exceptions are also thrown by other builtins in case of error.
halt(halt
Halt the system, exiting to the invoking shell.
Usage: * ISO *
basic_props:native/1
)
halt(Code)
Halt the system, exiting to the invoking shell, returning exit code Code
.
Usage: * ISO *
Code
is an integer.
(basic_props:int/1
)
abort(abort
Abort the current execution.
Go to the first, previous, next, last section, table of contents.