Slide 16 of 37

Mutability and value semantics

proc main(): void {
	mut Str[dyn] a = ["x", "y"]
	mut Str[dyn] b = a       // an alias: two names, one header
	append(b, "z")            // len(a) is now 3 too
	echo a

	b = ["replaced"]          // rebinding one rebinds both
	echo a
}
Variables are immutable unless marked mut. Vectors, tables, maps and the declared types built from them are value types: two names for one value never observe each other's writes — unless both are mut, which is how sharing is opted into. A mutex parameter (v: mut T) is the one place storage crosses a call boundary on purpose, and only a proc may declare one; whether a call shares the caller's storage or a copy depends on whether the caller waits for it there or fires it with async.