# Vdm-sl in this specification

The current vdm-sl standard does not provide facilities for readily defining the concurrent actions, related state changes nor of the co-routine like behaviour of iterators in Sather. It is hoped that suitable mathematical abstractions will be developed in the future to do this - when this specification can be revised.

In the interim, however, the following adaptations of the spirit of vdm-slhave been made in order to more clearly define the meaning of programs and class features.

## Sather vis-a-vis vdm-sl Types

As an object-oriented language, Sather source text uses an implicit object argument to a method. Vdm-sl does not permit this. Every formal signature, therefore, includes as a first argument, the object as 'self'. In order to avoid problems where self may be of a class which has type parameters, the type of self is always written as SAME throughout this document, where this is defined individually in the class specifications.

Other types in library and pervasive class definitions are given the Sather name - which is defined in the appropriate class specification. A link to that definition is given for all references which occur in any other class!

## Iterators

Iterators are specified in terms of pseudo-vdm-sl expressions which make use of a local sequence component of iter state identified as history - together with its old name "history~". This is an adaptation of the history feature of vdm++; it is an empty sequence when the iter is first called. For an iter which yields values it is a sequence of previously yielded values; where no value is yielded it is a sequence of state changes. The objective of this is to specify when an iterator should quit in terms of equality between this history and some desired result set.

Consider the following example in which the iterator being specified is supposed to yield all of the possible indices of some array object in increasing order. The signature of this would be written in Sather as :-

ind! : CARD

The formal vdm-sl version of the signature will then look like -

ind_iter(self : SAME) yld : nat

with pre-condition -

pre self.size <> 0

in which, since the argument type is not an optional one, the more usual Sather pre-condition specifying that self should not be void is unnecessary. The post-condition is then defined as -

post ((history~ = [])
or (yld > tl history~))
and (history = history~ ^ yld)

while the quit condition is modelled as an errs clause -

errs QUIT : (set dom history~ = set dom inds self) -> quit

where the quit statement is defined in section six of this specification.

## Program State

A formal vdm-sl specification of a system, not using modules, has a single state component. For the purposes of easier reading individual state components are included in the sections and class definitions as they arise. Only one instance of each component is included.

## Abstract Classes

Each abstract class is viewed in this definition as a set of all instances of any class sub-typing from it. This permits the ready application of typecase constructions using the type_of auxiliary function.

| Specification Index |  | Language Index

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