Skip to content

Commit

Permalink
Merge pull request #475 from WebAssembly/elaborate-structured-control…
Browse files Browse the repository at this point in the history
…-flow

Clarify well-structured control flow
  • Loading branch information
kripken committed Dec 8, 2015
2 parents b621477 + a181137 commit 33e6a23
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 33e6a23

Please sign in to comment.