Skip to main content

Module builtins

Module builtins 

Source
Expand description

The builtin layer: arithmetic evaluation (arith), standard term order (order), and the C-ABI predicate surface (pred) that compiled code calls into for is/2, arithmetic/term comparison, \=/2, compare/3, cut, and codegen helpers.

The M4 deterministic builtins live in their own family modules: typecheck (var/atom/number/… type tests), termops (functor/arg/ =../copy_term), atomops (atom_length/concat/chars, number_chars/ codes), sortops (msort/sort), and miscops (succ/plus/ unify_with_occurs_check/write/writeln/nl).

Semantics are ported byte-for-byte from patch-prolog v1 so error message text and ordering decisions stay identical; see the per-module docs.

Modules§

arith
Arithmetic expression evaluation (is/2, comparisons).
atomops
Atom/number-string builtins: atom_length/2, atom_concat/3, atom_chars/2, number_chars/2, number_codes/2.
facts
Fact-table lookup (FACT_TABLE.md, Stages A–C): the generic enumerator for a predicate compiled to a .rodata table instead of one function per clause. Same observable behavior as the per-clause facts — solution order = program order, choice-point backtracking — mirroring between/3’s shape.
miscops
Miscellaneous deterministic builtins: succ/2, plus/3, unify_with_occurs_check/2, write/1, writeln/1, nl/0.
order
Standard order of terms (ISO 8.4.2), ported from patch-prolog v1’s term_compare.
pred
C-ABI surface for the M3 builtins: arithmetic (is/2, comparisons), term comparison (==, @<, compare/3), structural inequality (\=/2), cut, and a few codegen helpers. Mirrors the style of abi.rs (#[unsafe(no_mangle)] pub extern "C" fn plg_rt_*).
sortops
List-sorting builtins: msort/2, sort/2.
termops
Term-introspection builtins: functor/3, arg/3, =../2 (univ), copy_term/2.
typecheck
Type-checking builtins: var/1, nonvar/1, atom/1, number/1, integer/1, float/1, compound/1, is_list/1.