![]() |
Section 8.16.1.4: |
![]() |
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.
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 a mutable string of any kind which may be imported or exported from/to the program environment. Because it is mutable it is possible to create and manipulate strings of this kind with lower overheads than for a corresponding immutable string.
This feature returns the size of the string as a count of elements contained.
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.
This feature returns the number of elements in the string.
NOTE | This is not necessarily directly related to storage size occupied (see the definition of the octets feature below). |
This feature provides the facility to determine how many storage octets are occupited by the string, irrespective of kind or size of string element.
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.
This post-condition is much weaker than that for the size feature. This arises from the necessarily implementation-defined (possibly even dynamic) relation between element count and storage octets occupied.
This feature returns the number of storage units (octets) occupied by the string.
This feature is provided to enable a program to use external environment services in relation to a string. It returns an environment-specific reference to the string.
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.
Since the result of this feature is implementation-dependent no post-condition can be specified (except to state here that the reference is required to be a valid handle for self.
This feature provides an environment-defined handle for the contents of self (for use in external input or output).
This feature is provided to enable a program to manipulate independently a sub-string starting at the beginning (head) of the string.
This feature is required to operate successfully whatever the value of cnt may be. The pre-condition is therefore vacuously true.
This feature provides either cnt elements from the head of self or the contents of self if that contains fewer elements.
This feature corresponds to the head feature above - this time returning the last portion of the string.
This feature is required to operate successfully whatever the value of cnt may be. The pre-condition is therefore vacuously true.
This feature provides either cnt elements from the tail of self or the contents of self if that contains fewer elements.
This feature enables a program to extract an arbitrary number of string elements in string form.
This feature provides the substring of num elements of self beginning with the one whose index is one greater than beg.
NOTE | Indices used in Sather programs start with zero, those in vdm-sl are ordinal numbers starting from 1. |
This feature returns the index in the string at which the next element to be added will be placed. Note that this is expected to be equal to the string size.
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.
This feature provides the location where the next following string insertion will take place.
This feature is the 'writer' routine corresponding to the above 'reader'. Note that this could be implemented as a publicly visible attribute of the defining class.
This feature provides the facility for altering the location for next insertion, provided that it is either immediately after the current end of the string or an arbitrary location within the body of the current string.
![]() |
Language Index | ![]() |
Library Index | ![]() |
String Index |
Comments or enquiries should be made to
Keith
Hopper. Page last modified: Thursday, 20 July 2000. |
![]() |