Specification
This section is the authoritative reference for the Zirric programming language. It covers every construct the language supports — syntax, semantics, and runtime behavior.
How to use this section
The specification is split into four pages. Start with whichever matches your question:
Syntax — The formal grammar. Use this when you need to know what is valid to write: tokens, keywords, operator precedence, and the EBNF productions for every construct. No semantic explanations — just structure.
Declarations — How named entities are introduced:
const,var,fn,data,union,attr,extern,mod,import. Covers scoping rules, attribute application and validation, and where type hints appear on declarations.Expressions — How values are computed: literals, operators, calls, member and index access, closures with capture semantics, and all control flow (
if,for,switch,is,return,break,continue). Covers expression vs. statement forms and evaluation order.Type System — How types work at runtime: the four type categories (
data,union,extern type,attr), construction and identity, union membership, type hints and composite type expressions,ismatching rules, and protocol attributes like@Countableand@Iterable.
Quick reference
| I want to know… | Go to |
|---|---|
| Is this syntax valid? | Syntax |
| What operators exist and their precedence? | Syntax § Operator Precedence |
How does const vs var capture in closures? |
Declarations § const / Expressions § Closures |
| How do I declare and apply attributes? | Declarations § attr / Declarations § Attributes on Declarations |
How does switch case is matching work? |
Expressions § Switch |
What does is @Attr check? |
Type System § Attribute Types |
| What type hint forms are available? | Type System § Type Hints |
| How do unions and membership work? | Type System § Union Types |
How does for iteration work under the hood? |
Expressions § For / Type System § Protocol Attributes |