Next: raise
, Previous: try-catch
, Up: Exception Handling [Contents][Index]
try-until
The try-until
statement allows you to execute instructions until
some exception is caught. The syntax is:
try stmt until exp
where stmt is the statement that will be executed repeatedly
until some exception is raised. If the raised exception has type
exp then execution continues normally. exp should be an
expression that evaluates to an Exception
.
This statement is particularly useful for mapping IO spaces until an
eof
condition occurs. For example, this is how we would
compute with every integer in the current IO space:
var o = 0#B; try { compute (int @ o); o = o + 1#B; } until E_eof;
It is possible to leave the loop from within stmt using the
break
statement.