Version: 1.1.0

Compile-time cheat sheet

Facts you give the compiler.

Essentials

  • Parameters live in square brackets.
  • alias names a compile-time constant or type.
  • comptime if and comptime for run during compilation.
  • comptime assert fails the build.
  • A parameter used in ordinary code becomes a runtime constant.

Example

alias N = 4
fn main():
    comptime assert N == 4
    print(N)

Keep in mind

Compile-time code must be free of I/O that depends on a particular machine state unless that state is the target itself.