The joys of failure in Icon
An Icon expression can produce any number of results---zero, one, two, a million. The results are produced in sequence, one at a time.
The evaluation of expressions in Icon depends on the context from which the expression is evoked:
v := e''), an expression is evaluated only until it either fails (produces no values) or succeeds (produces at least one value).
every e1 do e2'' clause, though, it may produce any number of values.
The fact that expressions can fail actually makes it easier to handle exceptional cases. Suppose you are writing a procedure that computes the root of an equation, but some equations have no root. Rather than having to figure out what value you should return in that case, the procedure can simply fail.
You can test to see if a procedure failed. For example:
if not Some_Proc ( ) then...where ``
Some_Proc'' is some procedure that may fail.
John Shipman, firstname.lastname@example.org
Last updated: 1996/01/06 21:12:57 UT