Docs menu

Language

The reference for Turf 2.0: what you can write, and what it means. Start at the top and read down, or jump to the topic you need.

Every Turf program in these pages is compiled by the language repository’s CI: an example either compiles, or is marked with the error code it must be rejected with. The pages here show real output, and the red error boxes are real compiler messages.

Where to start

Core language

  1. Variables and Types: declarations, guess inference, definite assignment, the primitive types, literals, overflow, to conversions, sizeof / typeof.
  2. Operators: the precedence table, arithmetic and its runtime checks, comparison, logical, bitwise, give / otherwise.
  3. Control Flow: if, while, do / while, for, break / continue, defer, compare and the pattern language.
  4. Error Handling: error types and payloads, !T, recover, try, caller-located panics.

Structuring programs

  1. Functions and Modules: fn, first-class functions, UFCS, annotations, import, the prelude, pub visibility.
  2. Structs and Enums: declaration, construction, methods, layout cycles, self-referential types, enum.
  3. State Machines: the machine construct and its checked transitions.
  4. Generics and Operator Overloading: monomorphized generics, the overloadable operators, indexing operators.
  5. Arrays: fixed-size arrays, T[] parameters and slicing, bounds checking.

Memory and systems programming

  1. Memory and Safety: the two heaps, heap(expr), &T / &?T, escape rules, runtime checks, what safe code guarantees.
  2. FFI and unsafe: extern fn, linking C libraries, raw pointers, unsafe blocks and modules, capabilities.

Beyond this section

In this section

Last updated: Oct 15, 2026Edit this page on GitHub

Esc

Type to search.