CHP Deterministic Selection - The HAC Language
Description: The HAC Language

Next: CHP Nondeterministic Selection, Previous: CHP Guarded Commands, Up: CHP Statements

#### 14.4.3 Deterministic Selection

- CHP-det-selection : `[` CHP-det-guarded-command-list `]`
- CHP-det-guarded-command-list : CHP-guarded-command `[]` ...

The guarded command list must contain at least two guarded commands (else it's not a selection). The last guarded statement may be an else clause.

Operational Semantics: (Basically exclusive switch-case.) Only one of the guards is allowed to be true at a time (mutual exclusion). If more than one guard is ever true, then there is an error in the program. A deterministic selection blocks until one of its guards has become true and its guarded commands executed.

Execution: Since branches are executed mutually exclusively, as soon as any branch finishes executing its last event, the events that immediately follow the selection may be processes as if in the same sequence. If at any time more than one guard evaluates true, a diagnostic is required, though signaling and error is recommended.

If initially none of the guards evaluate true, then the selection is blocked until one of them becomes true. (This can be accomplished by registering all dependent variables on a global watch-list. When any variable on the watch-list changes status, then subscribed expressions are re-evaluated, to see if new events may be scheduled.)

If the guards include an else-clause, then this selection never blocks, because the else-clause will guarantee that one clause will execute.