From d3433ed0175df9bce5f9f1b9a9c25f3cddc2a189 Mon Sep 17 00:00:00 2001
From: James Clark Statement execution
describes how each kind of statement is evaluated, assuming that the evaluation
of those expressions and actions completes normally, and assuming that the
execution of any substatements does not cause termination of the current worker.
- Except where explicitly stated to the contrary, statements handle abrupt
-completion of the evaluation of expressions and actions as follows. If in the
-course of executing a statement, the evaluation of some expression or action
-completes abruptly with associated value e, then the current worker is
-terminated with termination value e; if the abrupt termination is a check-fail,
-then the termination is normal, otherwise the termination is abnormal. If the
-execution of a substatement causes termination of the current worker, then the
-execution of the statement terminates at that point.
+Except where explicitly stated to the contrary, statements handle abrupt
+completion of the evaluation of expressions and actions as follows. There are
+two possibilities.
+
+If the execution of a substatement causes termination of the current worker, +then the execution of the statement terminates at that point.
On fail clause class="grammar">stmt-with-on-fail := regular-compound-stmt on-fail-clause on-fail-clause :=+on
fail
typed-binding-pattern statement-block
+A stmt-with-on-fail
is executed by executing the
+regular-compound-stmt
. A check
expression or action,
+or a fail
statement may cause control to transfer to the
+on-fail-cause
. In this case, the typed-binding-pattern
+is matched to the associated error value, binding the variables occurring within
+the typed-binding-pattern
; the statement-block
is then
+executed with these bindings in scope. Otherwise, the
+on-fail-clause
is not executed.
+
+The static type of the associated error value is determined from the static type
+of the relevant check
expressions and actions, and
+fail
statements. It is a compile error unless the match of the
+typed-binding-pattern
with the associated error value is guaranteed
+to succeed by the static type of the associated error value.
+
fail-stmt :=+fail
expression;
+Executing a fail-stmt will cause control flow to transfer to the on-fail-clause +of the nearest lexically enclosing statement that has an on-fail-clause. If +there is no such statement, it terminates the current worker. +
++The static type of the expression must be a subtype of error. Execution of the +fail-stmt evaluates the expression; the resulting error value is passed to the +on-fail-clause or becomes the termination value of the current worker. +
+public
.
fail
statement has been added, along with a on
+fail
clause for compound statements. If a check
expression
+or action fails, it behaves like a fail
statement rather than a
+return
statement.