Open Manual

Nytrix quick reference

These are the rules most likely to conflict with habits from C, Rust, or Python. Each item links to the page with the complete contract.

Prerequisites: none; this is a lookup page.

Coming from another language

Coming from XYou might write YNytrix does Z
C, Rust, or Pythonlet value = 1let is rejected; use def value = 1 for an immutable binding or mut value = 1 for a reassignable binding.
C or Rustvalue; to end a statement; begins a comment; statement boundaries come from the grammar and source layout.
Pythonfor value in 1..4 and expect 4 to be excludedNytrix ranges include the end: this visits 1, 2, 3, and 4.
C or Pythonlist(3) to create three initialized elementslist(3) creates an empty list with capacity reserved; append before indexing.
Cnil as integer zeronil is a distinct value, though both are falsy.

Declarations and syntax

RememberNytrix ruleFull details
Types go firstfn greet(str name) str { ... }; a return type follows ).Syntax, Functions
Semicolons comment; starts a line comment. It never ends a statement.Syntax
Use fn for functions and lambdasFunction values use the same keyword as named functions.Functions
if is not pattern matchingif branches on truthiness; case dispatches values and inclusive ranges; match dispatches on patterns and ADTs.Control flow, Patterns
Ranges include the endfor x in 1..4 visits 1, 2, 3, and 4. case range arms are inclusive too.Control flow, Patterns
Counted loops are availablefor(mut i = 0 i < n ++i) { ... } keeps the counter binding in scope.Control flow
goto has cleanup rulesLeaving a scope runs its registered defer blocks.Control flow
del is a binding operationdel name needs a mutable binding; it sets that binding to nil and clears its flow facts. It does not free an object.Functions, Memory
Near-miss spellings never parselet, func, import, macro, var, void, and printf are all rejected with a message naming the supported spelling (def/mut, fn, use, quote with splicing, none, print).Syntax

Values and collections

RememberNytrix ruleFull details
nil is not zeroThey are distinct values and dictionary keys, although both are falsy.Values, Control flow
list(n) is emptyn reserves capacity; the initial length is zero. Append before indexing.Values, Troubleshooting
Bare {} is frozenIt is an immutable empty dictionary. Use dict() for a mutable empty accumulator.Values
Retain collection updatesList growth may return a replacement value; keep the return value. Use clone when an API needs a detached mutable container.Values, Functions
Indexing and get differDictionary indexing returns the runtime default when a key is absent; get(key, fallback) makes the fallback explicit.Values
Truthiness is broadZero, nil, empty strings, and empty containers are false. Pointers, handles, and callables are true.Control flow

Open representation defects in library code

These are compiler defects, not language rules: inside standard-library modules a value's raw/boxed representation can be lost at the boundaries below. Library code works around them as shown; remove a workaround only with a fixture that fails without it.

PatternSymptomWorkaround in the tree
A record from a ternary, def r = h ? dict_get(m, h, 0) : 0, then r = r.set(...)The record is typed int and stored back as a bare handle (the Wayland window table lost every field at fractional scales)Assign in an if
return d.set(k, v) from a function returning a recordThe caller receives a raw handleBind out = out.set(...), then return out
A local named s holding a dictIt reads as strUse another name
An empty list stored in a record, read in another moduleIt reads as an integerCheck is_list and fall back to []
A typed int parameter or C callback argument stored in a dictIt reads back as nil or halved__box_i64(v), or type callback parameters (i32 fd) instead of any
An int match payload appended to a list in a stdlib moduleIt is stored untaggedAppend h + 0
Reassigning an int parameter from min/maxThe value is halvedClamp into a fresh local
mut any x = dict(8) as a module globalThe global never holds the dictInitialise with the concrete type
.len read straight off an imported list global on --native-onlyWrong lengthBind to a typed local first
A stdlib function named like a core function (split)Calls inside the module reach it and crashUse a distinct name

Types, modules, and native code

RememberNytrix ruleFull details
module and #main serve two jobsA file can expose an importable module and have a direct-entry body guarded by #main.Units
struct and layout differstruct is a language value; layout fixes field order and representation for ABI use.Types, Native
Choose the execution pathDefault execution, --run=aot/--output, --native-only, and browser Wasm select different compiler paths. Unsupported forms can differ by path.Pipeline, Implementation status
Safety has levelsOwnership analysis is off by default. --borrow-check enables advisory diagnostics; --ownership-check=strict promotes supported rules, and --mode=safe also enables strict typing and tracked raw-memory checks.Ownership, Runtime
Attributes are an open namespaceAny @name parses and stays visible to reflection; behavior attaches only to the recognized set in Functions.Functions, Comptime

Threads and contracts

RememberNytrix ruleFull details
@thread depends on call positionA statement-position call detaches; using the call as a value joins and returns its result.Functions, Concurrency
Proof clauses are not a full theorem proverrequires, decreases, law, and @total have different checks and backend gaps. Check the current matrix before relying on them as a safety boundary.Proofs, Implementation status

For maturity and intended use, see Where Nytrix fits.

Next: