Skip to content

Add mutable and caller-reference parameters - #17

Merged
bytetroll merged 3 commits into
masterfrom
codex/matrix-mutable-parameters
Oct 29, 2026
Merged

bytetroll merged 3 commits into
masterfrom
codex/matrix-mutable-parameters

Conversation

@bytetroll

@bytetroll bytetroll commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Matrix now distinguishes reassignment of a function's local parameter from mutation of the caller's variable. mutable amount as number enables local reassignment (variable remains an alias); reference amount as number writes through to an explicitly passed reference to total. Ny retains mut amount: i64 and adds ref amount: i64 with ref total at the call. Both languages accept mut/mutable and ref/reference interchangeably, preserving their surrounding grammar: Matrix uses ref to total, while Ny uses reference total.

Writes are immediate, including when two parameters alias the same variable or a callee raises a fault. The initial reference profile supports exactly typed mutable scalar/text locals and parameters in ordinary non-generic named functions. Methods, aggregate/field/index/global targets, escaping references, and foreign reference boundaries are rejected.

  • Lower checked bindings to private typed cells shared by the VM and allocated on the native caller's stack. Validate schemas, calls, storage, and non-escaping lifetimes when compiling and loading textual/binary NIL.
  • Preserve ordinary VM callbacks and text operations in functions that use references. Existing native indirect-call limitations remain.
  • Update highlighting, completion, signature help, and debugger locals/watches. Fix modified parameters after and and variadic signature labels. Accept both keyword spellings in existing object references as well; signature help retains canonical Ny short and Matrix long spellings.
  • Document the contract in NIL-0019 and F75; record the separate existing Matrix type-alias/local-callable collision as unresolved F76.
  • Reserve both keyword spellings in both languages and rename existing test bindings that used the newly reserved Ny word reference.

Validation:

  • All 229 parameter checks pass across both frontends, textual/binary interpretation and bundles, JIT/AOT, unmanaged native execution, source/binary-library imports, aliasing, forwarding, shadowing, faults, and short/long keyword spellings. Ordinary callbacks retain their existing VM/bundle coverage.
  • All 252 NIL storage/lifetime checks pass through serialized readers and direct VM embedding. DAP tests inspect real compiled caller/callee values in both source languages and NIL encodings.
  • All 112 VS Code unit/grammar checks pass; repository policy and whitespace checks pass.
  • Full LLVM-enabled CTest suite plus targeted reruns after renaming two fixture bindings: 509 passed, no remaining failures, one optional PostgreSQL integration test skipped (510 registered). The complete run used two CPU cores and completed in 148 seconds; both corrected fixtures passed their subsequent run.

Preserve the NILData and binding-reference design records and findings while integrating the released serialization changes. Validated TypeScript checking, all 119 extension unit tests, and 16 SDK capability tests.
@bytetroll
bytetroll merged commit db8be48 into master Oct 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant