Expand description
Query-level control constructs and deterministic builtins.
Clause bodies compile control flow to native code; this module only
serves goals built at RUNTIME — the --query string today, call/1
metacalls in M4. It walks goal TERMS, never clauses (the rule in
docs/design/LESSONS_FROM_V1.md stays intact).
The implementations mirror the compiled lowering exactly (same choice-point shapes, same commit heights), so a goal behaves identically whether it appears in a clause body or a query.
Functions§
- plg_
rt_ ⚠b_ catch_ 3 - Safety
- plg_
rt_ ⚠b_ findall_ 3 - Safety
- plg_
rt_ ⚠b_ throw_ 1 - Safety
- plg_
rt_ ⚠metacall - Compiled-code entries for control builtins taking goal terms.
- plg_
rt_ ⚠metacall_ resolve - Fast-path resolver for the metacall trampoline (#23): if
goalis a simple compiled-predicate call (after peeling a singlecall/1wrapper), marshal its arguments and return the entry function pointer as an integer for generated IR tomusttailinto — givingcall(pred(...))tail recursion constant C stack, like a direct call. Returns 0 for anything the full walker must handle (builtins, control constructs,call/Nwith extra args, variables, undefined predicates); the caller then falls back toplg_rt_metacall, which is bounded by the depth guard incall_goal. - plg_
rt_ ⚠pred_ between_ 3 - Compiled-code entry for between/3 (uniform predicate signature, arguments in the A registers — dispatched like a user predicate).
- try_
atom_ builtin - Atom-only goals (
true,fail,!). - try_
builtin - Try to handle
name/arityas a control construct or deterministic builtin. Returns None when it’s an ordinary predicate call.