18 let statement
let statement allows limited form of pattern matching, with
terser syntax, for example patterns can be used to decomposite tuples,
like this:
*(int, int) t = (1, 2);
...
switch t {
case (i1, i2): return i1 + i2;
}
This can be abbreviated to:
*(int, int) t = (1, 2);
...
let (i1, i2) = t in return i1 + i2;
There can be more then one assignment, like this:
let (t1, t2) = t,
(s1, s2) = s in {
// ...
}
The let assignment and binding names with case just creates new name for
an object.
There is also second form of, that does not introduce new scope, but
binds names until end of current scope. It's called ``flying let'', and
is written as:
let (t1, t1) = t;
let x = foo();
bar(t1, x);
baz(t1, x);