Previous Page Next Page Contents

NIL -- the singleton element of the domain DOM_NIL

Introduction

NIL is a keyword of the MuPAD language which represents the singleton element of the domain DOM_NIL.

Call(s)


NIL

Related Functions

delete, FAIL, null

Details

Example 1

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}

Example 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.

Example 3

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:

Example 4

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:

Example 5

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:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000