Skip to main content

Module typecheck

Module typecheck 

Source
Expand description

Type-checking builtins: var/1, nonvar/1, atom/1, number/1, integer/1, float/1, compound/1, is_list/1.

Ported byte-for-byte from patch-prolog v1 (builtins.rs type-check arms). Each deref-tests a single tag. Notable v1 decisions, verified against the oracle:

  • integer/1 accepts both the immediate TAG_INT and the boxed TAG_BIG (v1’s Term::Integer covers the full i64 range).
  • compound/1 is TRUE for lists: v1 matches Compound { .. } | List { .. }, so a TAG_LST counts as compound (compound([1]) succeeds).
  • is_list/1 walks the tail iteratively and is true only for a proper, nil-terminated list (is_list([a|b]) fails).

Functions§

plg_rt_b_atom_1
atom/1: succeeds iff the argument is an atom.
plg_rt_b_compound_1
compound/1: a structure OR a list cell (v1 counts lists as compound).
plg_rt_b_float_1
float/1: a boxed float.
plg_rt_b_integer_1
integer/1: immediate TAG_INT or boxed TAG_BIG.
plg_rt_b_is_list_1
is_list/1: a proper (nil-terminated) list. Iterative tail walk so a long list can’t blow the C stack; a partial or improper list fails.
plg_rt_b_nonvar_1
nonvar/1: the negation of var/1.
plg_rt_b_number_1
number/1: any numeric tag (immediate int, boxed big, or float).
plg_rt_b_var_1
var/1: succeeds iff the dereferenced argument is an unbound variable.