Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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, 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. 
- 
-<code> 
-select { 
-  alt (g1) {...} 
-  alt (g2) {...} 
-  ... 
-} 
-</code> 
- 
-**Listing 1. ** Select statement syntax: ''g1'', ''g2'' stand for guards 
- 
- 
-**Example** 
- 
-<code> 
-select { 
-  alt (x == 0) { out a; } 
-  alt (x == 1) { out b; } 
-} 
-</code> 
- 
-**Listing 1. ** Example code layer with the select statement 
- 
- 
- 
-**[[:alvis:manual|Go back]]**