2. Language Elements : Variables : Reference Variables : Null Reference Variables
 
Share this page                  
Null Reference Variables
When you declare a reference variable without specifying default null, the variable points to an object whose attributes are automatically initialized with the default values given in the definition of the object. However, you can set a reference variable to null. A reference variable that is set to null does not point to any object. Whenever all reference variables for an object have been redirected or set to null, OpenROAD frees the associated object, for example, given the following declarations:
a = Addr;
b = Addr;
The consequences of resetting the variables a and b would be:
a = b;     /*  The original object for a is freed. Now
            ** both a and b point to the same object. */
a = null;  /*  The object created for b still has 1
            ** reference (b). */
b = null:  /*  The object created for b is freed. */
As an alternative, you can specify default null on the declaration and a default object is not created.
You can check for a null reference variable with the is null operator, for example:
if a is null then
    /* processing statements */
endif;
For more information about null reference variables, see Nulls in Expressions (see Nulls in Expressions).