Variables
Grammar: var-decl, typed-decl, assign, lvalue
x := value declares a variable and infers its type from the value, including a vector's length. Type x = value writes the type out. That is how a value that says nothing about its own shape, such as an empty vector or a new map, gets one, and it is the only way to say [dyn]. A length inferred from the value is still a fixed length: only a vector declared [dyn] can grow, with append, below.
A variable is immutable unless it is declared mut: it can be neither reassigned nor written through (v[0] = …, u.name = …), whatever its spelling. UPPER_CASE is only a convention for such a variable; mut is what decides.
A name is declared once per block. Declaring it again in the same block is a compile error, so assign to it instead. A block inside may declare its own, which hides the outer one until the inner block ends. _ := value throws a value away, as often as you like.
proc main(): void {
x := 1 // inferred, immutable
mut count := 0 // inferred, reassignable
mut Str[dyn] rows = [] // written out: an empty vector says nothing itself
MAX := 100 // immutable, and spelled like a constant
count = count + 1
append(rows, "first")
echo "{x} {count} {rows} {MAX}"
}proc main(): void {
mut total := 10
// total := 20 // compile error: `total` is already declared in this block
total = 20 // an assignment, which is what that line meant
_ := total * 2 // thrown away, on purpose
_ := total + 1 // and again: `_` is never declared
echo total
}Run a program to see what it prints here.