This is an old revision of the document!


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, if more than one branch is open the first of them is chosen to be executed. If all branches are closed, the corresponding agent moves to the first statement after the select one.

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: g1, g2 stand for guards

Example

select {
  alt (x == 0) { out a; }
  alt (x == 1) { out b; }
}

Listing 1. Example code layer with the select statement

Go back