VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 14. Top-level Specification (<strong>VDM</strong>++ and <strong>VDM</strong>-RT)<br />
Functions, operations, instance variables and constants 2 in a class may be either class attributes<br />
or instance attributes. This is indicated by the keyword static: if the declaration is preceded by<br />
the keyword static then it represents a class attribute, otherwise it denotes an instance attribute.<br />
Other class components are by default always either class attributes or instance attributes as<br />
follows:<br />
• Type definitions are always class attributes.<br />
• Thread definitions are always instance attributes.<br />
thread(s).<br />
Thus, each active object has its own<br />
• Synchronization definitions are always instance attributes. Thus, each object has its own<br />
“history” when it has been created.<br />
In addition, the interface or accessibility of a class member may be explicitly defined using an<br />
access specifier: one of public, private or protected. The meaning of these specifiers is:<br />
public: Any class may use such members<br />
protected: Only subclasses of the current class may use such members<br />
private: No other class may use such members - they may only be used in the class in which<br />
they are specified.<br />
The default access to any class member is private. That is, if no access specifier is given for a<br />
member it is private.<br />
This is summarized in table 14.1. A few provisos apply here:<br />
• Granting access to instance variables (i.e. through a public or protected access specifier)<br />
gives both read and write access to these instance variables.<br />
• Public instance variables may be read (but not written) using the dot (for object instance<br />
variables) or back-quote (for class instance variables) notation e.g. a public instance variable<br />
v of an object o may be accessed as o.v.<br />
• Access specifiers may only be used with type, value, function, operation and instance variable<br />
definitions; they cannot be used with thread or synchronization definitions.<br />
• It is not possible to convert a class attribute into an instance attribute, or vice-versa.<br />
• For inherited classes, the interface to the subclass is the same as the interface to its superclasses<br />
extended with the new definitions within the subclass.<br />
• Access to an inherited member cannot be made more restrictive e.g. a public instance variable<br />
in a superclass cannot be redeclared as a private instance variable in a subclass.<br />
133