First steps
Variables
Section titled “Variables”var declares a mutable binding; let is reserved for pattern-
binding (covered later). Annotate the type, or let the checker
infer it from the initialiser.
Numbers have sizes
Section titled “Numbers have sizes”There’s no untyped int. The eight integer types are i8, i16,
i32, i64 (signed) and u8, u16, u32, u64 (unsigned),
plus usize for native pointer-width counts. Two floats: f32
and f64. Mixing widths needs an explicit cast.
var a: i32 = 7;var b: i64 = a as i64; // narrow → wide castvar c: i32 = b as i32; // wide → narrow (may truncate)Control flow
Section titled “Control flow”if / else, while, and three-part for.
if is also an expression, for one-line ternaries.
var max: i32 = if (a > b) { a } else { b };Functions
Section titled “Functions”function add(a: i32, b: i32): i32 { return a + b;}Return and parameter types are always required — even void for
procedures. There’s no inference at the signature boundary.