Project

General

Profile

Feature #141

Updated by Eugen Wissner 7 days ago

## Rationale 

 For a low-level systems programming language it is important to have an escape from the structured flow. The escape route proposed here are named blocks with the support of break statements to exit the block. 

 ## Syntax 

 - The new keyword `block` is followed by an identifier, its name. The body of the block is a statement list ending with the `end` keyword. 
 - The new statement "break identifier" can be used everywhere in the block to jump to the end of the block with the named identifier. 
 - The block name in the block statement itself and in the break statement is mandatory. 

 ## Usage 

 - a `block` inside the a loop gives represents "continue". 
 - `block` outside of a `block` wrapping the loop gives represents a "break". 

 ## Symbol table 

 Labels Theoretically the labels can use their its own namespace since their usage doesn't conflict with any other symbols. Labels cannot be exported, their maximal scope is always a single procedure. The lookup is bottom-up as for other symbols. Labels name is only valid inside the block it is attached to. Label names cannot be shadowed by the nested blocks. 

 ## GENERIC generation 

 A block opens a new scope, as any other block-statement, since it is required to handle try…finally correctly. At the end of the block an artificial label should be generated, that is used to jump to it if a break-statement breaks that block. 

 A `break` runs the `defer`s of the scopes it leaves.

Back