Local bindings
Use name := expression; to declare an immutable binding.
base := 40;
factor := 3;
print(base + 2 * factor);
This file prints 46.
A binding is available after its initializer, so an initializer can refer to earlier bindings. Referencing an undefined name or declaring the same name twice is an error.
Names start with an ASCII letter or underscore and may also contain digits after the first character.
Mutable bindings
Use name :~ expression; to declare a mutable binding and
name = expression; to assign a new value. The new value must have the
type inferred from the initializer.
score :~ 38;
if score < 40 {
score = score + 2;
}
print(score);
This file prints 40. A block can assign to a mutable binding in an
enclosing scope. Function parameters are immutable.