Zane Foundations
This document states the few ideas the rest of the specification rests on. Every topic document builds on these ideas; this document names them in a single place and points to the document that specifies each one in full. This document introduces no rules of its own — another document specifies each foundation canonically, and this document is the map that shows how the foundations fit together.
See also:
lexical.md§3 for the casing rule.generics.md§2 and §7 for types-as-functions and uniform stride.memory.md§3 for layout.effects.mdfor how the strictness is enforced.
Story:
stories/foundations.mdexplains the story behind these commitments — the bets they represent and the costs they accept.
1. Overview
Zane is built on a small number of commitments that the rest of the language derives from. These commitments are not features; every feature is built on them. Read this document first, then read any topic document as a working-out of these ideas in one area.
Source is captured intent. Zane code is a high-level description of architecture and thought, not a transcript of machine steps. Zane code is high-level on purpose, because intent is clearest in a high-level form.Compilation is staged; types are values. A type is an ordinary compile-time value that the compiler executes in an earlier stage to produce a layout. Parameterization, and the split between type expressions and calls, follow from this staging.Layout is fixed. Every value of a given type is the same number of bytes. Uniform stride is a global invariant, not a per-type choice.Identity is opt-in. A type defined in Zane is a value unless it is marked#; the mark makes it a reference type with identity and aliasing, moved rather than copied. Value versus reference is one axis, orthogonal to the product/sum shape of the body.Strictness is the performance model. The language forbids high-level conveniences that would dissolve a low-level guarantee. The rules are not a tax paid alongside fast code — they are the mechanism that produces it.
2. Source Is Captured Intent
Zane source is meant to read as a captured idea — the shape of a program’s architecture and the thoughts behind it — rather than a step-by-step encoding of how a machine should proceed. This is why the surface is deliberately high-level: intent is clearest when it is expressed directly, not buried under manual bookkeeping.
The high level is not in tension with performance. Because the source carries intent rather than mechanism, the compiler is left with more freedom to choose the mechanism — provided the intent was expressed well. Expressing the intent well is not optional; the language’s rules (the rest of this document) force enough structure that the captured intent is unambiguous. A well-expressed Zane program is therefore both easier to read and easier to compile to fast code, for the same reason: nothing important was left implicit.
This framing recurs throughout the spec. The two parallel document sets — spec/ for what and stories/ for why — are the same idea at the level of the specification itself: capture the definition and the intent behind it, separately and explicitly.
3. Compilation Is Staged; Types Are Values
A type in Zane is an ordinary compile-time value. The compiler runs in stages: an earlier stage executes types — applying a parameterized type to its arguments to produce a concrete layout — before a later stage constructs and runs values. A type definition is, quite literally, a function from parameters to a layout.
Three consequences that other documents depend on:
- Parameterization is not a separate feature. It follows directly once a type is an executable value. A parameterized type lists its parameters and produces a result; applying arguments evaluates it. See
generics.md§2. <>and()are different mechanisms, not two call syntaxes.<>is a type expression, resolved in the earlier (type) stage;()is a construction or call, resolved in the later (value) stage. They live in different stages, which is why a call never carries a<>list. Seegenerics.md§4–§5.- A value passed at compile time is just an argument. A type or compile-time integer handed to a constructor is an ordinary value the body can use, because the stage that runs the type has those values in hand. See
generics.md§5.3.
Story:
stories/generics.md— “Types are templated functions” records why staging was chosen over a bolt-on generics sublanguage, and where the model promises more than it currently delivers.
4. Identifier Casing and Parsing
The surface grammar uses enforced identifier casing to simplify parsing and distinguish type names from value names. The initial-case rule and the ambiguities it resolves are specified by lexical.md §3 and §5. The casing rule supports the syntax; it does not define the staging, ownership, or layout model described here.
Story:
stories/lexical.md— “Casing separates types from values”.
5. Layout Is Fixed
Every value of a given type occupies the same number of bytes. Size is part of the type, not a runtime property of the value. This uniform-stride invariant is global: it holds for every type, all the way up every containment chain.
The uniform-stride invariant is the foundation of a large part of the runtime model:
- Indexing is
base + i * stridewith a compile-timestride; copying, struct embedding, and calling conventions all depend on a fixed size. The full argument is ingenerics.md§7. - A type whose size could vary would propagate that variability into everything that contains it, so the invariant has to be global to be worth anything.
- Consequences elsewhere are derivations of this rule, not separate decisions: an array bakes its length into its type (
generics.md§8), and a directly inline self-reference is impossible because it would have infinite size, which is why a recursive member is boxed rather than laid out inline — on either side of the#axis (adt.md§4,memory.md§3.3).
6. Strictness Is the Performance Model
Zane is strict — single ownership, fixed layout, read-only parameters, mandatory error handling — and this strictness is what produces its performance.
High-level expression, on its own, usually costs speed. What buys the speed back is that the rules preserve enough invariants for the compiler to generate good code without guessing: ownership is known, so destruction is deterministic and needs no collector; layout is fixed, so access is direct; effects are known, so independent work can be parallelized. Each rule that forbids a convenience is the same rule that licenses an optimization.
The rules are therefore not a usability tax levied next to the performance. They are the trade that produces the performance: give up the conveniences that would force the compiler to be conservative, and in exchange the compiler can be aggressive. This is why the language forbids, rather than merely discourages, the constructs that would dissolve a guarantee — a guarantee that holds only sometimes is one the compiler cannot rely on. The enforcement mechanisms live in memory.md, effects.md, and lifetimes.md; this section is only the principle that unifies them.
Story:
stories/foundations.md— “Strictness is the performance model” weighs this bet against the permissive alternative and records its real ergonomic cost.
7. Identity Is Opt-In
Every type defined in Zane is a value type unless it is marked with #, which makes it a reference type. This one axis is orthogonal to a type’s shape — such as a product struct or a sum variant — and everything that separates a plain value from a shared object follows from which side of the axis a type is on. The mark attaches only to a mould — #struct, #variant, #enum — or to a foreign handle — #handle (ffi.md §4.1) — declared and named; each such reference type is a distinct type with identity that can be pointed at. The compiler’s intrinsic types are defined nowhere in Zane and carry no mark; the compiler instead fixes whether each is a value type or a reference type: the scalar primitives @primitives$I32, @primitives$I64, @primitives$F32, and @primitives$F64, @primitives$U8, @primitives$Bool, @primitives$String (types.md §2.7), @primitives$ByteSet (types.md §2.12), @primitives$Array<T, n>, and @primitives$List<T> are value types, while @primitives$ArrayRef<T, n>, @primitives$ListRef<T> (generics.md §8), and the runtime’s @runtime$Console and @runtime$Runtime (effects.md §6.6) are reference types.
A value type is copied on assignment, has no identity, and — the load-bearing restriction — is transitively a value: it may contain only other value types, never a reference-type or & field. Nothing reachable from a value can be aliased, which is why a value can be copied and shared by snapshot with no bookkeeping. A reference type is the opposite in each respect: it has stable identity, may be aliased through &, may hold reference-type and & fields, and reaches a new place by being moved rather than duplicated.
The axis does not affect recursion: either kind may contain itself, through a member the compiler boxes. That rule and the reasoning behind it belong to adt.md §4.
Both kinds are mutated in place through a mut method, and the subject is written the same way in each — bare this, no marker — and in both kinds the subject is a borrow of the caller’s value or owner, so a value is mutable without gaining identity and an object is mutable without the method taking ownership. Neither consumes the caller’s owner.
#is the only kind modifier, applied uniformly to any type. Seetypes.md§2 andadt.md§2–§3.- A value type is transitively value (no reference-type or
&field, anywhere downstream). This closed value world is specified bymemory.md§2.10. - A value copy is deep. Copying a value copies every payload it owns out of line into fresh storage, which is what lets a value type recurse without ever aliasing. See
memory.md§2.3. &rides on#. A non-owning&exists only for reference types; a value is shared by copy or by a scoped borrow, never by a stored&. Seememory.md§2.4.- A reference names an owner that never moves. An owner is either settled — referenceable, never moving again — or roaming — movable, and referenced by nothing. A new
&is minted only from a settled place, so the object it names stays where it is until its scope drains. Seememory.md§2.1, §2.8, and §2.8.1. - Concurrency depends on this axis. A spawned call may mutate only a value-typed subject, because a value’s transitive alias-freedom is exactly what lets the compiler rule out a data race from the signature alone. A worker pool’s element may be a reference type only when every
&in it names a constant. Seeconcurrency.md§4 and §6.4.
Story:
stories/foundations.md— “Identity is opt-in: one axis for value and reference”.
8. Summary
| Foundation | Commitment | Canonical home |
|---|---|---|
| Captured intent | Source expresses architecture and intent, not machine steps; high-level on purpose | this document |
| Staged compilation | Types are compile-time values executed in an earlier stage; <> and () are different stages |
generics.md §2, §4–§5 |
| Fixed layout | Every value of a type is the same size; uniform stride is global | generics.md §7, memory.md §3 |
| Identity is opt-in | A type defined in Zane is a value unless marked #; # adds identity and &-aliasing and makes the type moved rather than copied; a value type is transitively value, and either kind may recurse through a boxed member |
memory.md §2, types.md §2, adt.md §2–§3 |
| Strictness is performance | Forbidding guarantee-dissolving conveniences is what licenses aggressive codegen | memory.md, effects.md, lifetimes.md |