Changes between Version 37 and Version 38 of Language
- Timestamp:
- 05/21/23 10:26:43 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Language
v37 v38 341 341 342 342 A `$choose` statement has the form 343 `$choose` `{` ''stmt''+ ( `default` `:` ''stmt'' )? `}` 344 For example, 345 343 346 {{{ 344 347 $choose { 345 stmt1; 346 stmt2; 347 ... 348 default: stmt 348 $when (x<n) x++; 349 $when (s>0) s--; 350 $default: c++; 349 351 } 350 352 }}} 351 353 The default clause is optional. 354 352 355 The guards of the statements are evaluated and among those that are true, one is chosen nondeterministically and executed. 353 356 If none are true and the default clause is present, it is chosen. … … 417 420 418 421 A guarded command is encoded in CIVL-C using a `$when` statement: 419 {{{ 420 $when (expr) stmt; 421 }}} 422 All statements have a guard, either implicit or explicit. For most statements, the guard is''true''.422 `$when` `(` ''expr'' `)` ''stmt'' 423 424 Semantics: all CIVL-C statements have a guard, either implicit or explicit, which specifies when the statement is enabled. 425 For most statements (e.g., assignments), the guard is implicitly ''true''. 423 426 The `$when` statement allows one to attach an explicit guard to a statement. 424 427 425 When `expr` is''true'', the statement is enabled, otherwise it is disabled.428 At a state in which the guard evaluates to ''true'', the statement is enabled, otherwise it is disabled. 426 429 A disabled statement is blocked—it will not be scheduled for execution. 427 When it is enabled, it may execute by moving control to the `stmt` and executing the first atomic action in the `stmt`. 428 If `stmt` itself has a non-trivial guard, the guard of the `$when` statement is the conjunction of the `expr` and the guard of `stmt`. 429 430 The evaluation of `expr` and the first atomic action of `stmt` occur as a single atomic action. 431 There is no guarantee that execution of `stmt` will continue atomically if it contains more than one atomic action, i.e., other processes may be scheduled. 430 When a `$when` statement is enabled and scheduled for execution, it executes by moving control to ''stmt'' and executing the first atomic action in ''stmt''. 431 432 If ''stmt'' itself has a non-trivial guard, the guard of the `$when` statement is the conjunction of ''expr'' and the guard of ''stmt''. 433 434 The evaluation of ''expr'' and the first atomic action of ''stmt'' occur as a single atomic action. 435 There is no guarantee that execution of ''stmt'' will continue atomically if it contains more than one atomic action, i.e., other processes may be scheduled. 432 436 433 437 ==== Example
