News flash: I'm going to Australia in February, so this Web site may be switched off at any time.


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:

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.
Next: Using generators in Icon
See also: Using the Icon programming language
Previous: Branching in Icon

John W. Shipman, john@nmt.edu