Variables
Variables in Do are dynamically typed and lexically scoped. They must be declared before use.
Declaration with let
Introduce new variables with let:
The right-hand side of let is a compact expression context, so variables and
calls work without $:
It can also be a complete command statement:
Assignment
Reassign an existing variable with =:
Assignment does not declare a new variable; the variable must already be bound
by let, a function parameter, for, bind, or another binding form.
Scoping
Variables are lexically scoped to the block where they are declared:
Functions close over their defining scope:
Closures can mutate captured variables: