Project

General

Profile

Actions

Feature #210

open

Block-local variables

Feature #210: Block-local variables

Added by Eugen Wissner 6 days ago. Updated 6 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Language
Start date:
Due date:
% Done:

0%

Estimated time:

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.

Actions

Also available in: PDF Atom