Sather Home Page

Section 8.1.1.6:
$STR

abstract class $STR

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 ;
$STR = set of object_type
<> state

multi : $STR
inv multi_types ==
forall obj in set multi_types & sub_type($STR,obj)
NOTE See the important note about vdm state in the notes on vdm-sl usage in this specification.

This abstract class models the text string representation of an object of the implementation class sub-type. Any such representation should, for portability purposes, be in accordance with the forms defined in this library.


str

This feature requires the sub-typing class to implement a method of deriving a text string representation from the value of an object of the class. The text string shall be in the form and encoding specified by the execution environment indicated by the argument.

str (
lib : LIBCHARS
) : STR
Formal Signature
str(self : SAME, lib : LIBCHARS) res : STR
Pre-condition

Note that in contrast to a pre-condition written in Sather source code, in vdm-sl neither the type SAME nor the type LIBCHARS are optional types and therefore both self and lib must exist, leading to the vacuous pre-condition - true.

Post-condition

Since the value of the result is not determinable statically, the formal post-condition is also vacuously true, with the rider, informally, that the string shall be a text representation of the value of the object in a coding which can be rendered into a visible image for a human reader.

This feature returns a value which is a textual representation of the value of self using the character repertoire and encoding defined by the argument.


str

This variant of the str feature is required to produce a representation of the value in the execution environment of the program when running.

str : STR
Formal Signature
str(self : SAME) res : STR
Pre-condition

As with the above version of this feature, 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.

Post-condition

In common with all other text string representation features, the value of the result is not determinable statically, thus the formal post-condition is vacuously true. The informal rider to this is that the result is a text string representation encoding suitable for rendering to become visible to a human user.

This feature returns a value which is a textual representation of the value of self using the environment default character repertoire and encoding.


Language Index Library Index Basic Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Wednesday, 24 May 2000.
Produced with Amaya