- Documentation
- Reference manual
- Foreign Language Interface
- The Foreign Include File
- Argument Passing and Control
- Atoms and functors
- Analysing Terms via the Foreign Interface
- Constructing Terms
- Unifying data
- Convenient functions to generate Prolog exceptions
- Foreign language wrapper support functions
- Serializing and deserializing Prolog terms
- BLOBS: Using atoms to store arbitrary binary data
- Exchanging GMP numbers
- Calling Prolog from C
- Discarding Data
- String buffering
- Foreign Code and Modules
- Prolog exceptions in foreign code
- Catching Signals (Software Interrupts)
- Miscellaneous
- Errors and warnings
- Environment Control from Foreign Code
- Querying Prolog
- Registering Foreign Predicates
- Foreign Code Hooks
- Storing foreign data
- Embedding SWI-Prolog in other applications
- The Foreign Include File
- Foreign Language Interface
- Packages
- Reference manual
pen_query()">PL_open_query()
had the flag int PL_cut_query(qid_t
qid) Discards the query, but does not delete any of the data created by the
query. It just invalidates qid, allowing for a new call to
PL_open_query()
in this context. PL_cut_query()
may invoke cleanup handlers (see setup_call_cleanup/3)
and therefore may experience exceptions. If an exception occurs the
return value is
int PL_close_query(qid_t
qid) As PL_cut_query(),
but all data and bindings created by the query are destroyed as if the
query is called as
qid_t PL_current_query(void) Returns the query id of the current query or
PL_engine_t PL_query_engine(qid_t
qid) Return the engine to which qid belongs. Note that interacting
with a query or the P
PL_Q_EXT_STATUS
, there are additional return
values (see section
12.4.1.2).
FALSE
and the exception is accessible
through PL_exception(0)
.
An example of a handler that can trigger an exception in PL_cut_query() is:
test_setup_call_cleanup(X) :- setup_call_cleanup( true, between(1, 5, X), throw(error)).
where PL_next_solution()
returns TRUE
on the first result and the throw(error)
will only run when PL_cut_query()
or
PL_close_query()
is run. On the other hand, if the goal in
setup_call_cleanup/3
has completed (failure, exception, determinitic success), the cleanup
handler will have done its work before control gets back to Prolog and
therefore PL_next_solution()
will have generated the exception. The return value PL_S_NOT_INNER
is returned if qid is not the innermost query.
\+ \+ Goal
. This reduces the need for
garbage collection, but also rewinds side effects such as setting global
variables using b_setval/2.
The return value
PL_S_NOT_INNER
is returned if qid is not the
innermost query.0
if the
current thread is not executing any queries.