nx_primitive_registry.nx
buildroot/runtime/nx_primitive_registry.nx
about
nx_primitive_registry.nx -- callable-by-name primitive catalog.
Per user 2026-05-15: "actually ingest and use all the algorithms
known as primitives as callable elements like functions like other
systems".
THE PATTERN (NumPy / SciPy / Mathematica / MATLAB):
- Every primitive has a stable name (string)
- The catalog records (name, signature_id, domain, complexity,
provenance), enabling discovery and introspection
- Lookup-by-name returns a stable IntID; downstream code
dispatches by ID for performance
- Per-domain query lets the user enumerate "what physics
primitives are available?"
NOTE: NishiLang doesn't yet have first-class function pointers in
the user-source surface, so the registry stores METADATA + a stable
dispatch_id. Caller chooses to invoke by direct symbol name (the
fast path -- L3 callable) OR via the dispatcher (the slow but
uniform path). Adding first-class fn pointers is a named blocker
for full Mathematica-style Symbolic[] dispatch and is on the
compiler-improvements queue.
dependencies 1 imports · 1 importers
imports: nx_kernel_v2.nx
imported by: nx_capabilities_test.nx
structs
| 62 | struct PrimEntry |
| 73 | struct PrimRegistry |
consts
| 33 | const NX_DOMAIN_LOGIC: nx_int = 1 // kernel rules + propositional engine |
| 34 | const NX_DOMAIN_ARITH: nx_int = 2 // nat / int / rat / real Term substrate |
| 35 | const NX_DOMAIN_LINALG: nx_int = 3 // vec / matrix |
| 36 | const NX_DOMAIN_CALC: nx_int = 4 // symbolic derivative / integral |
| 37 | const NX_DOMAIN_PHYSICS: nx_int = 5 // units + dim analysis + dynamics |
| 38 | const NX_DOMAIN_CHEM: nx_int = 6 // atomic table + stoichiometry |
| 39 | const NX_DOMAIN_PROB: nx_int = 7 // probability + statistics |
| 40 | const NX_DOMAIN_PROOF: nx_int = 8 // proof construction (engine + tactics) |
| 41 | const NX_DOMAIN_RENDER: nx_int = 9 // visual output (CLI + browser) |
| 42 | const NX_DOMAIN_DATA: nx_int = 10 // sketches / hashes / encodings |
| 45 | const NX_COMPLEX_O1: nx_int = 1 |
| 46 | const NX_COMPLEX_O_LOG_N: nx_int = 2 |
| 47 | const NX_COMPLEX_O_N: nx_int = 3 |
| 48 | const NX_COMPLEX_O_N_LOG_N: nx_int = 4 |
| 49 | const NX_COMPLEX_O_N2: nx_int = 5 |
| 50 | const NX_COMPLEX_O_N3: nx_int = 6 |
| 51 | const NX_COMPLEX_O_2N: nx_int = 7 |
| 52 | const NX_COMPLEX_NP: nx_int = 8 |
| 58 | const NX_PRIM_PROVED_NATIVE: nx_int = 0 |
| 59 | const NX_PRIM_PENDING: nx_int = 1 |
| 71 | const NX_PRIM_BYTES: nx_int = 56 |
| 78 | const NX_PRIM_REG_BYTES: nx_int = 24 |
functions
| 80 | func nx_prim_registry_new(cap: nx_int) -> *PrimRegistry |
| 88 | func nx_prim_at(r: *PrimRegistry, i: nx_int) -> *PrimEntry |
| 93 | func nx_prim_register( |
| 116 | func nx_prim_lookup(r: *PrimRegistry, name: *u8, name_len: nx_int) -> nx_int |
| 137 | func nx_prim_count_by_domain(r: *PrimRegistry, domain: nx_int) -> nx_int |
| 149 | func nx_prim_count_by_status(r: *PrimRegistry, status: nx_int) -> nx_int |
| 161 | func nx_prim_domain_name(d: nx_int) -> *u8 |