Language reference
Syntax, evaluation rules, runtime contracts, and the Elder toolchain.
Reference scope
Reviewed against the Elder source at 1b579a456463 (December 1, 2026). Start with the language tour or try the runnable examples.
Names, statements, and access
Declare a binding with name := value and update it with name = value. To write through a path, its parent must already exist. Names are case-sensitive and unresolved bare names raise an error.
Newlines usually terminate statements. A leading or trailing infix operator can continue the statement, as can a line beginning with a tight member access such as /run(). A semicolon or a period followed by whitespace or end of file explicitly terminates the statement. A sign attached to a numeral starts a signed literal.
value/member walks a value, value[key] looks up an index or key, and dotted names group declarations, arguments, and namespaces. ./, ../, and ~/ address the current, parent, and root scopes. Whitespace between terms can invoke a callable.
Values and typed collections
Elder has booleans, integers and decimal numbers, strings, bytes, null, containers, and callable values. Double-quoted strings allow interpolation with braces. Single-quoted and triple-quoted strings are useful for literal text.
Give known data a named, closed type. For example, Person::(name: string) declares a type you can construct with Person(name = "Ada") and use in a binding or parameter. Use list(int) for numeric sequences and map(string, int) for a dictionary with runtime keys.
Bare containers are useful when code deliberately inspects data of an unknown shape. A missing container key resolves to null. A missing member on a closed functor throws. Open functors allow late-bound members.
Use null for a missing value and some(value) for a present optional value. value ?? default evaluates the fallback only when needed. Null propagates through member paths, with length and size returning zero.
Operators and control flow
Tight a/b accesses a member. Spaced a / b and a ÷ b divide. Use spaces around infix symbols. The registered prefix forms !flag, not flag, and -x bind more tightly than infix operators.
The arithmetic tiers start with ^ (integer XOR), then * / %, then + - << >>, then comparisons. Logical and/or short-circuit, and the pipe |> binds below the logical tiers. Use math/pow(a, b) for powers and parentheses to make grouping explicit. Symbolic functors can be overridden in scope or on a receiver.
Use if and else for branches, for (items) [item] { ... } and while for loops, and try, catch, and raise for errors. A used if result carries taken and value. Scope overrides can delegate to the original control-flow functors via the root scope.
Functors and arguments
name::(params) { body } defines a callable. Calls accept positional arguments and named arguments written with =. Defaults belong to the formal parameter list. A body can return a single value or let the call yield an instance whose named members provide the outputs.
An ordinary argument evaluates eagerly. A defer parameter evaluates on first read and memoizes its result. A reevaluate parameter evaluates on each read. Pass blocks as execution arguments and use explicit arguments where implicit binding would hide the source of a value.
... forwards container entries through ordinary argument binding. call(./...) spreads the current scope, including entries unrelated to the intent of the wrapper. Forward a deliberately shaped record at API boundaries.
Types, contracts, and inheritance
Type annotations on bindings and parameters validate or coerce values at their boundary. Binding data to a named, closed type rejects missing required fields, unknown fields, and values that cannot be coerced to the declared field type. Write field?: T for an optional field or parameter. Use open(T) when the contract intentionally accepts additional fields.
Nominal types resolve in the current module first. Built-in type names have canonical lowercase identities, and ambiguous unqualified nominal matches fail. Templates can constrain type parameters. Use a static contract to express a structural requirement on more than one nominal type.
Inherited typed fields must retain compatible types. With ELDER_STRICT_FIELD_WRITES=strict, writes through a closed functor instance check the declared field type. The source default at this revision warns for the migration. See Contracts for shape composition, constructors, and type checks.
Modules, packages, and native code
Module members are private until explicitly exported. Use include to compose source and import("package", "version") to resolve an installed package. A qualified package name resolves through configured package roots and the runtime registry policy.
The default package resolution mode is installed_registry_only. It checks configured roots and allows the non-discovering Lite registry fallback. elder package build stages and validates a package before switching its manifest to a new generation. Use --check for a build that leaves the package root untouched.
Native packages and Elder functions use the same invocation surface. Explicit unsafe { ... } regions are required for operations marked requires_unsafe. The interpreter and AOT share the language contract. See Tooling for build, diagnostic, and source-emission commands.
Ownership and concurrency
borrow and borrow/mutable express shared and mutable borrows. move invalidates the source binding, while copy and clone follow the value's copy or clone policy. Task boundaries enforce local, sendable, and shareable policies.
Use task_group to own related work, channel or actor to pass messages, and atomic or mutex for synchronized shared mutation.
A task-group join reports per-task status. A timeout bounds the wait. Set abort_on_timeout = true to cancel queued work and interrupt running Elder code at cooperative checkpoints. Native work can outlive that wait. See Concurrency for cleanup and cancellation.
I/O, persistence, and data
Use io/fs and io/http for filesystem and HTTP operations, and io/process/run(argv = [...]) to run an explicit argument vector. File descriptor I/O supports optional timeouts where documented.
Use fs/load and fs/commit for snapshots, store/* for revision-checked per-record writes, and durable/* for typed persistent records. store/transaction commits grouped writes atomically and rolls back if the block throws.
Decode Elder data text with eval(text, execute = false, duplicate_keys = "reject") and bind the result to your named type before reading its fields. The data-only parser accepts literals, containers, and constructor-shaped data. It rejects executable expressions and uses max_source_bytes, max_nodes, and max_depth to bound each decode.
The default limits are 1 MiB of source, 1,000,000 AST nodes, and a depth of 256. Per-call overrides are positive integers capped at 64 MiB, 16,000,000 nodes, and a depth of 1,024. See I/O and storage and the standard library guide.
CLI arguments and shell mode
Native Elder flags precede the script path. The script receives the remaining tokens, after Elder consumes one optional leading --. Use cli("argv") for the exact raw tokens and cli("option", fallback) for parsed option values. fetch(limit: number = 10) declares a typed option and rejects an invalid CLI value with exit status 2.
The #!shell pragma enables shell command syntax. An absolute executable path such as /bin/echo explicitly selects an external command. Bound Elder expressions such as n > 2 retain their Elder meaning. Use shell/parse when tooling needs the shell pipeline's structure and individual word parts.