Next / Previous / Index / TCC Help System / Publications / Site map / NM Tech homepage

The joys of failure in Icon

Tech Computer Center logo

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: A tutorial for the Icon programming language
Previous: Branching in Icon
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Computer Center: Help System
TCC Publications
Home: About New Mexico Tech

John Shipman, john@nmt.edu

Last updated: 1996/01/06 21:12:57 UT
URL: http://www.nmt.edu/tcc/help/lang/icon/joyfail.html