NIL
-- the singleton element of the
domain DOM_NIL
NIL
is a keyword of the MuPAD language which
represents the singleton element of the domain DOM_NIL
.
NIL
DOM_NIL
has only one singleton
element. NIL
is a keyword of the MuPAD language
which represents this element. NIL
is not changed by
evaluation, see DOM_NIL
.NIL
is used to represent a ``missing'' or
``void'' operand in a data structure. The ``void object'' returned by
null
is not suitable for
this, because it is removed from most containers (like lists, sets or
expressions) during evaluation.DOM_ARRAY
is created, its elements
are initialized with the value NIL
. The function op
returns NIL
for
un-initialized array elements. Note, however, that an indexed access of
an un-initialized array element returns the indexed expression instead
of NIL
.proc
are initialized with
NIL
. Nevertheless, a warning is printed if one accesses a
local variable without explicitly initializing its value.NIL
was used to
delete values of identifiers or entries of arrays or tables, by
assigning NIL
to the identifier or entry. This is no
longer supported. One must use delete
to delete values.
NIL
now is a valid value of an identifier and a valid
entry of an array or table.Unlike the ``void object'' returned by null
, NIL
is not removed
from lists and sets:
>> [1, NIL, 2, NIL], [1, null(), 2, null()], {1, NIL, 2, NIL}, {1, null(), 2, null()}
[1, NIL, 2, NIL], [1, 2], {NIL, 1, 2}, {1, 2}
NIL
is used to represent ``missing''
entries of procedures. For example, the simplest procedure imaginable
has the following operands:
>> op(proc() begin end)
NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL
The first NIL
, for example, represents the
empty argument list, the second the void list of local variables and
the third the void set of procedure options.
Array elements are initialized with NIL
if
not defined otherwise. Note, however, that the indexed access for such
elements yields the indexed expression:
>> A := array(1..2): A[1], op(A,1)
A[1], NIL
>> delete A:
Local variables in procedures are implicitly initialized
with NIL
. Still, a warning is printed if one uses the
variable without explicitly initializing it:
>> p := proc() local l; begin print(l) end: p():
Warning: Uninitialized variable 'l' used; during evaluation of 'p' NIL
>> delete p:
NIL
may be assigned to an identifier or
indexed identifier like any other value. Such an assignment no longer
deletes the value of the identifier:
>> a := NIL: b[1] := NIL: a, b[1]
NIL, NIL
>> delete a, b:
NIL
to identifiers or entries of arrays or
tables does no longer delete their values.