Docs menu

How the compiler works

These pages explain how Turf is built: how the compiler turns text into a program, how names and types are tracked, and what runs underneath your program.

You do not need any of this to write Turf programs. It is here for anyone who wants to understand, check or contribute to the compiler. Most pages have two halves: what a Turf programmer observes, and how the compiler implements it, so the two can be compared.

  1. The Compiler Pipeline: from a .tr file to a native binary.
  2. Modules and Scope Resolution: imports, visibility, type identity and ::.
  3. The Memory Model: stack, heap and static data; copies and aliases.
  4. Pointers and References: ptr, T*, &T, &?T and the analyses that keep them safe.
  5. Errors and recover: the recoverable-error system, pass by pass.
  6. Caller Location: how a panic names the caller’s line.
  7. The Runtime: libturfrt, linked into every binary.
  8. The Boundary: what the compiler, the library and the runtime each own.
  9. Contributing: reporting a problem, building, and sending a change.
  10. Testing the Compiler: the test suites, and how to add a test for a fix.

In this section

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

Esc

Type to search.