Reference
Language
Syntax and rules for the A7 language surface that examples use today.
Language
This page is the short operational reference. Full semantics are in docs/SPEC.md. Verified examples live under examples/, especially 037_language_tour.a7.
Program shape
Top-level bindings and functions use ::. Functions use fn, explicit ret, and typed parameters.
io :: import "std/io"
greet :: fn(name: string) {
io.println("Hello, {}!", name)
}
main :: fn() {
greet("A7")
}
Declarations
- Top-level constants and functions:
name :: value - Mutable locals with inference:
count := 0 - Explicit type:
count: i32 = 0
Control flow
Use if, while, for, break, continue, and match. A7 source recursion is rejected at compile time. Rewrite recursive algorithms with loops, index worklists, or explicit stacks.
sum_to :: fn(n: usize) usize {
total: usize = 0
i: usize = 0
while i <= n {
total = total + i
i = i + 1
}
ret total
}
Indexed iteration:
for index, value in items {
// index is usize
}
Types
Examples and docs may use:
- Integers and floats
bool,char, strings- Fixed arrays and slices
- Structs, enums, and untagged unions
- References with nil checks
- Simple generic functions and structs
Reserved or incomplete areas belong in Status, not in examples that pretend they are complete.
Imports
Standard library imports use virtual module paths:
io :: import "std/io"
math :: import "std/math"
Local file imports are being extended for multi-file programs. Generated Zig remains single-file output.
Hard rules
- A7 source recursion is rejected. Use loops, index worklists, or explicit stacks.
- Use
usizefor sizes, lengths, capacities, and indexes. - Reserve
isizefor signed pointer-sized offsets and position differences. new [N]Tis rejected. Use stack arrays or slices.- Public reference syntax does not expose address-of or dereference operators. Pass lvalues directly to
refparameters.