# Section 8.1.1.2:
$IS_NIL

###### abstract class $IS_NIL

#### Formal Definitions

This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.

types
SAME = object_type ;
$IS_NIL = set of object_type
state
multi : $IS_NIL
inv multi_types ==
forall obj in set multi_types & sub_type($IS_NIL,obj)

NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification.

This abstract class defines the concept of being able to determine if an object is the nil value (See also the abstract class $NIL. This abstraction must not be confused with the vdm concept of nil!

This class defines the following single feature.

#### is_nil

This abstraction defines a feature for testing whether or not the value of an object is such that the class involved deems it to be a 'null' value. This does not mean that it is an invalid value or'no' value at all.

is_nil | : BOOL

##### Formal Signature

is_nil(self : SAME) res : BOOL

##### Pre-condition

Note that in contrast to a pre-condition written in Sather source code, in vdm-sl the type SAME is not an optional type and therefore self must exist, leading to the vacuous pre-condition - true.

##### Post-condition

This post-condition is defined using the 'nil' value (nil_val) produced by an actual class which also inherits from $NIL. In Sather there would be a circular inheritance path if this abstract class inherited from $NIL, rather than the other way round as it is currently defined.

post let comp : $NIL be st comp = comp.nil_val in
res = (self = comp)

This predicate returns true if and only if self is the nil value for this class.

| Language Index |  | Library Index |  | Basic Index

Comments or enquiries should be made to Keith Hopper . Page last modified: Tuesday, 23 May 2000. |