The Zane Language Specification
The meaning of every construct of the Zane language, the set of legal programs, and how memory, effects and packages work.
The specification is a reference, not a tutorial: to learn the language, start with the Learn pages. The design stories record the history of each design decision.
Each rule is specified in exactly one document, the rule’s canonical home; every other document that mentions the rule links to that home.
Foundations
| Document | Purpose |
|---|---|
foundations.md |
The few cross-cutting commitments the whole spec rests on: captured intent, staged compilation, fixed layout, opt-in identity, and strictness-as-performance — start here |
Reference documents
| Document | Purpose |
|---|---|
syntax.md |
Canonical surface syntax for every construct |
lexical.md |
Case-sensitive parsing, identifier formation, the casing-determines-kind rule, and numeric and string literal forms |
glossary.md |
Canonical names for recurring concepts and coined spec terms |
Type system and runtime model
| Document | Purpose |
|---|---|
types.md |
Fundamental types, value/reference types, fields, constructors, implicit conversions, type/alias declarations, and the string primitive’s numbers, bytes, and byte sets |
adt.md |
Enums, variants, the struct/variant symmetry, pattern matching, match, and enum maps |
functions.md |
Methods, free functions, subscripts, overload resolution, function values, and lambdas |
generics.md |
Unified type parameters, <> type expressions, constructor calls, and the Array, ArrayRef, List, and ListRef container primitives and their operations |
memory.md |
Ownership, settled and roaming owners, references, and arena layout |
lifetimes.md |
Lexical lifetime rules, moves, scope rules, and deterministic destruction |
effects.md |
The effect model, mut, read-only bindings, what each kind of verb may write, capability wiring, and compile-time evaluation, implicit and marked with comptime |
concurrency.md |
Implicit parallelism, spawn, worker pools, water-tower lifetimes, concurrency safety, and a host’s calls into exported lambdas |
Programs and program structure
| Document | Purpose |
|---|---|
control-flow.md |
Block arguments, the control-flow intrinsics, the core branching, repetition, and workers built on them, and 1-based ordinal rules |
operators.md |
Operator set, derived operators, intersection and union, operands passed as written, and precedence |
math.md |
The @math$ intrinsics — bit operations, square root, rounding, trigonometry — exact and approximate functions, and the math package that declares them over core’s Int and Float |
error-handling.md |
Bifurcated return paths, ? handlers, and abort/resolve semantics |
packages.md |
The lib/, bin/ and test/ project layout, library packages and their subpackages, file-scoped imports, explicit member access, package visibility, package-scope state, parameterized packages and their instances, the program and test packages that hold main, and the plugin packages and exported lambdas a host loads |
dependencies.md |
Package identity, manifests, test dependencies, package renames, version pinning, fetching, and caching |
ffi.md |
Calling C: a package’s C code and the toolchain that builds it, foreign verbs and the types that cross into C, the context a callback gets back, foreign handles, foreign capabilities and the foreign variables that give them, and what foreign code is taken to read and write |
Reading order
Read foundations.md first: it states the few commitments the rest of the language rests on. Then, roughly in this order:
syntax.md, for what each construct looks like;types.mdandfunctions.md, for types, constructors and methods;memory.mdandlifetimes.md, for ownership and references, where Zane differs most from other languages;effects.md, for what a call is allowed to change;packages.md, for how a project is laid out.
Look up unfamiliar terms in glossary.md. When a rule seems strange, its design story usually explains the reason for the rule: each spec section with a story behind it links to the story’s chapter.
The spec describes the language; the compiler implements the language, and lists where the compiler differs from the spec in its docs/spec-divergences.md, checked against the spec commit named there.