This section documents the built-in predicates that deal with engines. In addition to these, most predicates dealing with threads and message queue can be used to access engines.
- [det]engine_create(+Template, :Goal, ?Engine)
- [det]engine_create(+Template, :Goal, -Engine, +Options)
- Create a new engine and unify Engine with a handle to it.
Template and Goal form a pair similar to findall/3:
the instantiation of Template becomes available though engine_next/2
after Goal succeeds. Options is a list of the
following options. See thread_create/3
- Give the engine a name. Name must be an atom. If this option is provided, Engine is unified with Name. The name space for engines is shared with threads and mutexes.
- Set the limit for the global stack in KBytes.
- Set the limit for the local stack in KBytes.
- Set the limit for the trail stack in KBytes.
- [semidet]engine_next(+Engine, -Term)
- Ask the engine Engine to produce a next answer. On this first call on a specific engine, the Goal of the engine is started. If a previous call returned an answer through completion, this causes the engine to backtrack and finally, if the engine produces a previous result using engine_yield/1, execution proceeds after the engine_yield/1 call.
- [det]engine_next_reified(+Engine, -Term)
- Similar to engine_next/2,
but instead of success, failure or or raising an exception, Term
is unified with one of terms below. This predicate is provided primarily
for compatibility with Lean Prolog.
- Goal succeeded with Template bound to Answer or Goal yielded with a term Answer.
- Goal failed.
- Goal raises the error Exception.
- [det]engine_post(+Engine, +Term)
- Make Term available to engine_fetch/1 inside the Engine. This call must be followed by a call to engine_next/2 and the engine must call engine_fetch/1.
- [det]engine_post(+Engine, +Term, -Reply)
- Combines engine_post/2 and engine_next/2.
- Called from within the engine, causing engine_next/2
in the caller to return with Term. A subsequent call to engine_next/2
to `return'. This predicate can only be called if the engine is not
involved in a callback from C, i.e., when the engine calls a predicate
defined in C that calls back Prolog it is not possible to use this
predicate. Trying to do so results in a
- Called from within the engine to fetch the term made available through engine_post/2 or engine_post/3. If no term is available an existence_error exception is raised.
- Called from within the engine to get access to the handle to the engine itself.
- True if Term is a reference to or the alias name of an existing engine.
- True when Engine is an existing engine.