Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | Both sides next revision | ||
| alvis:select [2015/11/24 17:09] marcin | — (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Select statement ====== | ||
| - | The **select** statement provides a selective wait for one or more alternatives. The statement may contain a series of **alt** clauses called **branches**. Each branch may be guarded. These guards divide branches into **open** and **closed** ones. A branch is called **open**, if it does not have a guard attached or its guard evaluates to **True**. Otherwise, a branch is called **closed**. To avoid indeterminism, | ||
| - | |||
| - | A **guard** is a Haskell logical expressions placed inside round brackets. | ||
| - | |||
| - | |||
| - | The **select** statement is a multi-step statement. The first step consists of evaluating the guards and entering the corresponding branch (if possible). Then, a model executes steps inside the branch. | ||
| - | |||
| - | < | ||
| - | select { | ||
| - | alt (g1) {...} | ||
| - | alt (g2) {...} | ||
| - | ... | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | **Listing 1. ** Select statement syntax: '' | ||
| - | |||
| - | |||
| - | **Example** | ||
| - | |||
| - | < | ||
| - | select { | ||
| - | alt (x == 0) { out a; } | ||
| - | alt (x == 1) { out b; } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | **Listing 1. ** Example code layer with the select statement | ||
| - | |||
| - | |||
| - | |||
| - | **[[: | ||