Asks pengine NameOrID a query Query.
Options is a list of options:
- template(+Template)
- Template is a variable (or a term containing variables)
shared with the query. By default, the template is identical to the
query.
- chunk(+IntegerOrFalse)
- Retrieve solutions in chunks of Integer rather than one by one. 1 means
no chunking (default). Other integers indicate the maximum number of
solutions to retrieve in one chunk. If
false
, the Pengine
goal is not executed using findall/3 and
friends and we do not backtrack immediately over the goal. As a result,
changes to backtrackable global state are retained. This is similar that
using set_prolog_flag(toplevel_mode, recursive)
.
- bindings(+Bindings)
- Sets the global variable’$variable_names' to a list of
Name = Var
terms, providing access to the actual variable
names.
Any remaining options are passed to pengine_send/3.
Note that the predicate pengine_ask/3
is deterministic, even for queries that have more than one solution.
Also, the variables in Query will not be bound. Instead,
results will be returned in the form of event terms.
- success(ID, Terms, Projection, Time, More)
- ID is the id of the pengine that succeeded in solving the
query.
Terms is a list holding instantiations of Template. Projection
is a list of variable names that should be displayed. Time is
the CPU time used to produce the results and finally, More is
either
true
or false
, indicating whether we
can expect the pengine to be able to return more solutions or not, would
we call
pengine_next/2.
- failure(ID)
- ID is the id of the pengine that failed for lack of a
solutions.
- error(ID, Term)
- ID is the id of the pengine throwing the exception.
Term is the exception's error term.
- output(ID, Term)
- ID is the id of a pengine running the query that called
pengine_output/1. Term
is the term that was passed in the first argument of pengine_output/1
when it was called.
- prompt(ID, Term)
- ID is the id of the pengine that called pengine_input/2
and Term is the prompt.
Defined in terms of pengine_send/3,
like so:
pengine_ask(ID, Query, Options) :-
partition(pengine_ask_option, Options, AskOptions, SendOptions),
pengine_send(ID, ask(Query, AskOptions), SendOptions).