Skip to content

Commit

Permalink
elaborate on what well-structured control flow means
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Dec 3, 2015
1 parent b621477 commit a181137
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions AstSemantics.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,15 @@ Branches that exit a `block`, `loop`, or `tableswitch` may take a subexpression
that yields a value for the exited construct.
Branches may only reference labels defined by an outer *enclosing construct*.
This means that, for example, references to a `block`'s label can only occur
within the `block`'s body. In practice, outer `block`s can be used to place labels for any
given branching pattern, except for one restriction: one can't branch into the middle of a
loop from outside it. This restriction ensures all control flow graphs are well-structured.
within the `block`'s body.

In practice, outer `block`s can be used to place labels for any given branching
pattern, except for one restriction: one can't branch into the middle of a loop
from outside it. This restriction ensures all control flow graphs are well-structured
in the exact sense as in high-level languages like Java, JavaScript, Rust and Go. To
further see the parallel, note that a `br` to a `block`'s label is functionally
equivalent to a labeled `break` in high-level languages in that a `br` simply
breaks out of a `block`.

### Yielding values from control constructs

Expand Down

0 comments on commit a181137

Please sign in to comment.