There are many possibilities for block assignment semantics. Ideally I would like expression blocks and the top level to basically follow the same rules (possibly modulo overloading). With most options there is a problem of premature variable references, before they're assigned. Basically they can be treated as if they are void or don't exist, much as we do now.
One extreme is that no shadowing is allowed and everything has scope everywhere. This could potentially make for very prickly code. The other extreme is that everything has scope strictly downwards, except for consecutive function definitions which also have scope within their group (for mutual recursion). This eliminates the premature reference issue, but is rather restrictive.
My current proposal is this:
- Functions are arbitrarily recursive and all are in scope throughout their block. Multiple definitions are overloads or illegal.
- Variables have scope strictly downward. Shadowing is allowed accordingly.
In this case, premature references are always indirect (variable 1 calls function 3 refs variable 2; variable 2 calls function 1 calls function 4 refs variable 3).
There are many possibilities for block assignment semantics. Ideally I would like expression blocks and the top level to basically follow the same rules (possibly modulo overloading). With most options there is a problem of premature variable references, before they're assigned. Basically they can be treated as if they are void or don't exist, much as we do now.
One extreme is that no shadowing is allowed and everything has scope everywhere. This could potentially make for very prickly code. The other extreme is that everything has scope strictly downwards, except for consecutive function definitions which also have scope within their group (for mutual recursion). This eliminates the premature reference issue, but is rather restrictive.
My current proposal is this:
In this case, premature references are always indirect (variable 1 calls function 3 refs variable 2; variable 2 calls function 1 calls function 4 refs variable 3).