Skip to content

Clarify well-structured control flow #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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