Sather Home Page

Section 8.15.1.2:
SYS

class SYS

Formal Type

This class is more a grouping of utility routines than a class. It has no state associated with it - and therefore no creation routine.

types

SYS = token

The routines contained in this class are generic, relating to any kind of object and providing essential common functionality needed at the lowest level when implementing a library.



destroy

While the specification of the language itself requires that any implementation provide garbae collection, occasions may arise, particularly where a local heap item is being discarded, when it is possible to give the garbage collector a hint that something is finished with. This destroy operation is designed to provide this hint. It may, being only a hint, be ignored by any garbage collector implementation.

destroy (
anything : $OB
)
Formal Signature
destroy(anything : $OB)

This very special routine is provided for use on those rare occasions when it is known that explicit object destruction is appropriate. At the very least, this routine can be ignored - at the most it could immediately garbage collect the object. The choice of action is implementation-dependent.


is_eq

This equality test is provided for situations in which a class may not necessarily have specified an equality predicate based on the value of the objects being compared. This feature therefore provides an equality test that the two objects being compared are (or are not) the same object.

is_eq (
obj1 : $OB
obj2 : $OB
) : BOOL
Formal Signature
is_eq(obj1, obj2 : $OB) res : BOOL

This predicate returns true if and only if the two objects are determined to be the same according to some implementation-defined rule.


is_lt

This feature provides an ordering facility on objects in an implementation-defined manner. The implementation must guarantee that a total ordering on objects is provided.

is_lt (
obj1 : $OB
obj2 : $OB
) : BOOL
Formal Signature
is_lt(obj1, obj2 : $OB) res : BOOL

This predicate returns true if and only if obj1 is less than obj2 according to some implementation-defined rule.


hash

This feature provides a hash value on any object, based upon its identity rather than its value.

hash (
obj : $OB
) : CARD
Formal Signature
hash(obj : $OB) res : CARD
Post-condition

This makes use of the set 'objects' which contains all of the possible objects which could ever exist in a program. The post-condition is therefore an ideal rather than always practical since there is a limitation on the domain of CARD which does not apply to the domain nat!

post let res1 = hash(obj),
res2 = hash(obj) in
res1 = res2
and not exists entity in set dom objects & entity <> res and hash(entity) = hash(obj)

This routine shall produce a hash value in such a way that repeated application to the same object yields the same hash value but that application to all other possible objects does not yield the same hash value.


id

This feature provides an implementation-defined identifying code for any object.

id (
obj : $OB
) : REFERENCE
Formal Signature

id(obj : $OB) res : REFERENCE

This routine returns the implementation-dependent identity for the object given.


tp

This feature returns a code value which identifies the type of the argument in an implementation-dependent manner. The prime function of this is to provide an argument value from which str_for_tp can provide a text string version of the name(see below).

tp (
obj : $OB
) : REFERENCE
Formal Signature
tp(obj : $OB) res : REFERENCE
Post-condition

Note that the vdm function type_of is defined in section 6.9.

post res = type_of(obj)

This routine returns a unique reference to the type of the argument object.


str_for_tp

This feature provides a facility to obtain a string representation of the name of the type in the coding and representation in use when the class was translated. It may be necessary, therefore, to convert the encoding if a representation suitable for a human reader is needed (see the class STR).

str_for_tp (
obj : $OB
) : STR
Formal Signature
str_for_tp(ref : REFERENCE) res : STR
Pre-condition
pre let type_refs : set of REFERENCE =
{tp_ref in set dom forall obj in set objects type_of(obj)} in
ref in set type_refs

This routine returns a string in the current default repertoire and encoding which is a textual representation of the name of the type the reference to which is the argument.


rune_name

This feature is provided for use when using the resource components of the internationalisation facilities in order to obtin a portable name for the type concerned. This may then be used in looking up the localised resources during programme execution.

rune_name (
obj : $OB
) : RUNES
Formal Signature
rune_name(ref : REFERENCE) res : RUNES
Pre-condition
pre let type_refs : set of REFERENCE =
{tp_ref in set dom forall obj in set objects type_of(obj)} in
ref in set type_refs

This routine returns the programmer defined class name for the given object in the form of runes (encoded in ISO/IEC 10646-1 encoding). This is required for the internationalisation features of this library.


Language Index Library Index Sather RT Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Monday, 22 May 2000.
Produced with Amaya