![]() |
Section 7.2.4:
|
![]() |
NOTE | The TUP 'constructor' mechanism specified here is a value constructor defined for any number of class arguments of arbitrary classes/types. The result is thus a family of types. The language defines this in a similar way to record types in other languages. There are no restrictions on how such a type is to be implemented. In particular, the implementer is free to arrange value in store in any convenient way. See, however, external classes where placement is required. |
There is no way in which this type can be specified formally in vdm-sl, since it is effectively an infinite set of types. The expressions below are therefore written to express the intent of the definition rather than a completely correct definition for any one instance of the type family.
This particular class is defined here as an example of tuple construction. The features given below are defined for each variant, the sole change being the number of attributes and the number of arguments to the creation routine.
Note that the provision of the 'hash' and 'str' features in this pre-defined class is expected to mean that an implementer defines this class to inherit from $HASH and $STR. This is not, however, a requirement of the language.
This variant of a tuple class defines two read/write components.
Application of the create feature returns a new tuple irrespective of the values of the parameters given.
create | ( |
first : T1 | |
second : T2 | |
) : SAME |
Note that neither the parameters nor result are optional types and cannot therefore be nil.
This routine creates a two-component tuple with the given argument values.
The equality of two tuples relies on all component equality tests being true.
This predicate returns true if and only if both (all) of the components of self and other are equal. Note that this predicate may be used in an infix logical expression.
This hash feature should provide a deterministic numeric result which, for any particular tuple, has an equal probability of being any value in the cardinal number domain.
Note that the return type of this function is given as nat for the use of those implementers who do not wish to implement the Required Library. Where an implementatiion does include the Required Library then this is to be replaced for implementation purposes by the Required Library class CARD.
hash | : nat |
The result of applying this feature is a deterministic implementation-defined value.
This routine returns a simple hash value computed from the component hash values of the tuple. The computation is implementation-defined except insofar as it must be deterministic.
This representation feature is dependent on the culture (and encoding) in which the program is currently executing.
The result of applying this feature is a text string, the encoding and character repertoire of which are determined by the system and culture in which the program is executing. The requirement for a size of at least five in this particular variant provides for two bracketing and one separating glyph in addition to a minimum of one representing each value.
This routine returns a string representation of the tuple using the default repertoire and encoding.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Section 7 Index |
Comments
or enquiries should be made to Keith Hopper. Page last modified: Wednesday, 25 October 2000. |
![]() |