Project

General

Profile

Actions

Feature #141

open

Structured goto with blocks

Feature #141: Structured goto with blocks

Added by Eugen Wissner 2 months ago. Updated 7 days ago.

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

0%

Estimated time:

Description

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 loop gives "continue".
  • a block wrapping the loop gives "break".

Symbol table

Labels can use their 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 defers of the scopes it leaves.

Updated by Eugen Wissner 7 days ago · Edited Actions #1

  • Subject changed from Support goto and labels to Structured goto with blocks

Updated by Eugen Wissner 7 days ago Actions #2

  • Description updated (diff)

Updated by Eugen Wissner 7 days ago Actions #3

  • Description updated (diff)
Actions

Also available in: PDF Atom