Transparent Runtime Closures, Second Attempt
Some thoughts on how to do native runtime closures in Scopes in a transparent, yet controllable way:
While we're typechecking a function, the function is eventually accessing a runtime variable outside its function scope. Currently, I'm detecting that already, but just to produce a compiler error. But it could be allowed, and a environment record could be built as the function is typed, of all the expressions outside of its boundary that need to be put into it.
The only way we're going to get these expressions into the function is through an environment parameter of tuple type. So we're not just recording unbound variables, we also rewrite their access; a new equivalent value is added to the environment tuple, and the environment tuple entry is extracted instead. We also record in a map which exterior values need to be mapped to which member in the environment.
When we're done typing the function, we have a complete