HELP UNDEF                                   John Williams, January 1987

There is a built-in constant UNDEF whose value is the word "undef".
Hence

    "undef" = undef

is true. This word is used to initialise some data-structures, e.g.
vectors made with the procedure *INITV:

    initv(3) =>
    ** {undef undef undef}


There is also a class of objects of type 'undef'. When a variable is
first declared, its value is initialised to an undef record created from
the variable name. To illustrate:

    vars y;               ;;; First declaration of Y

    y =>
    ** <undef y>

Undef objects are recognized with the procedure *ISUNDEF. Their single
component (accessed with *UNDEFWORD) is the name of the variable for
which the undef record was originally created. So

    isundef(y) =>
    ** true

    undefword(y) =>
    ** y

Note that the value UNDEF is NOT an undef record, it is a word. So

    isundef(undef)

is FALSE.

Undef records can be created independently of variable declarations, by
using the procedure *CONSUNDEF. This takes a word as argument, and
returns an undef object whose *UNDEFWORD is that word. For example:

    consundef("x") =>
    ** <undef x>

Using CONSUNDEF, one could define the following routine to remove the
value of a named variable:

    define cancel_value(word);
        consundef(word) -> valof(word)
    enddefine;

An example:

    vars var;
    var =>
    ** <undef var>

    123 -> var;
    var =>
    ** 123

    cancel_value("var");
    var =>
    ** <undef var>

Note that CANCEL_VALUE does just that: it replaces the value of a
variable with an undef object. It does NOT cancel any special syntactic
properties the variable may have, such as being a syntax word, or an
infix operator. To properly cancel a variable, use the procedure
*SYSCANCEL, or the related macro *CANCEL.


See also:
    HELP *UNDEFWORD
    HELP *ISUNDEF
    HELP *CONSUNDEF
    HELP *VARS
    HELP *CONSTANT
    HELP *CANCEL

-----<Copyright University of Sussex 1987.  All rights reserved.>-------
