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 ``
/ e'' succeeds and returns the value of e if e is undefined; if e has a value, it fails.
\ e'' succeeds and returns the value of e if e has a value; if e is null, it fails.
There is a special predefined variable, ``
so this expression
foo := &nullcauses the variable
footo become undefined; any old value it might have had is discarded.
John Shipman, firstname.lastname@example.org
Last updated: 1998/02/08 23:14:08 UT