Skip to main content

Module order

Module order 

Source
Expand description

Standard order of terms (ISO 8.4.2), ported from patch-prolog v1’s term_compare.

Order: Var < Number < Atom < Compound

  • vars among themselves by heap-cell index (v1: VarId)
  • numbers by value; Float < Integer when numerically equal; NaN last
  • atoms alphabetically by name
  • compounds by arity, then functor name, then args left-to-right

A LST cell IS the compound '.'(Head, Tail) — arity 2, functor “.”. We treat it as such so a LST and a STR with functor “.” / arity 2 compare structurally equal, exactly as v1 (which has a distinct Term::List but compares it against Compound('.', [h, t]) as equal — see the List-vs-Compound arms in v1 term_compare).

Functions§

compare_terms
Total standard order over two heap words (after dereferencing).