Feature #210
openBlock-local variables
0%
Description
It should be possible to declare variables not only at the beginning of a procedure, but at the beginning of every block. Each block can therefore start with the var keyword introducing a variable declaration list. Because declarations are not separated by semicolons, an additional separator is needed, that introduces a statement list, that separator is begin.
To avoid going back to Pascal, where every block starts with begin, begin is optional when a block declares no variables. The consequence of this step is that, also a procedure body can be converted to a such block, so that a procedure that doesn't declare variables can skip var and begin, same as Oberon does not have them for block-statements.
Shadowing remains forbidden. The symbol table already supports nested scopes for for control variable. The semantic passes have to be extended to enter a scope for every compound statement.
case-branches count as blocks too.
Updated by Eugen Wissner 6 days ago
- Tracker changed from Bug to Feature
- Description updated (diff)