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


How does the null value work in Icon?

When you've declared a variable but before you've ever put anything in it, that variable is said to have the null value. If you try to perform computations on a null value, your program will terminate abnormally. This protects you from logic errors caused by using a variable that has never been defined.

You can test to see whether a variable is undefined (that is, whether it has a null value) by using the ``/'' and ``\'' operators:

There is a special predefined variable, ``&null'', so this expression

    foo  :=  &null
causes the variable foo to become undefined; any old value it might have had is discarded.
Next: Text processing in Icon
See also: Using the Icon programming language
Previous: Using the basic Icon types

John W. Shipman, john@nmt.edu