# Section 8.1.1.9:
$COPY

###### abstract class $COPY

#### 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 ;
$COPY = set of object_type
state
multi : $COPY
inv multi_types ==
forall obj in set multi_types & sub_type($COPY,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 an object of which a copy may be made. It provides the single feature defined below.

#### copy

This feature provides for the production of an exact copy of the object concerned.

copy | SAME

##### Formal Signature

copy(self : SAME) res : SAME

##### 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 pre-condition being vacuously true.

##### Post-condition

This post-condition equality is not the Sather object equality which would imply that self and res were the same object. Vdm-sl equality means equality of value.

post res = self

This feature returns a new object which has the same contents as self.

| Language Index |  | Library Index |  | Basic Index

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