# Examples 8.15.1.2:
SYS

The features of the required library class SYS are used in individual examples. None of the examples given is a complete class nor necessarily a 'complete' method.

#### destroy

Since Sather implementatioins are required to be garbage collected, it is not strictly necessary to explicitly discard objects which have been finished with. There are occasions where some object has merely been used temporarily in some method, will not be used again and could therefore be collected. This routine is provided to offer a hint ti a garbage collector which, since the garbage collector is not part of the Sather implementation, it may take or ignore at will, thus -

SYS::destroy(dummy)

is all that is needed to provide the hint!

#### is_eq

This predicate is provided to fill the gap for an object class which does not provide its own equality routine. This routine, however, does not test for equality of value, rather it tests that two objects are the same (in some implementation-defined way).

#### is_lt

This predicate is provided to fill the gap for an object class which does not provide its own is_lt routine. This routine, however, does not test for ordering of value, rather that the two objects themselves are ordered in some implementation-defined way.

#### hash

This routine provides a hash value based on the identity of the object rather than its value, thus

hash_val : CARD := SYS::hash(object)

>provides a value which may be used when inserting objects into maps or sets, dependent on how they may be implemented.

#### id

The notion of a unique identity for an object is very useful when interacting with some call-back mechanism and needing to despatch to the appropriate object based upon some value (the id!) returned by the external environment (eg a window manager). This all depends on whether the window manager provides the 'handle' or the Sather program. A call such as

obj_id : REFERENCE := SYS::id(object)

always yields a unique object identity token.

#### tp

This feature corresponds to the id one above; this, however, provides a unique reference to the actual type of the object concerned, thus -

type_ident : REFERENCE := SYS::tp(object)

NOTE | It is very important to remember that a bit-pattern forming a reference to a type might be identical to some other bit-pattern which is a reference to an object, or to some environmental reference, etc. It is the programmer's responsibility to avoid using the wrong reference in the right place!

#### str_for_tp

This feature is provided for use when preparing messages which need to refer to the type of some object in text string form, thus a type string could readily be produced by combining the 'tp' feature with this, to produce

type_name : STR := SYS::str_for_tp(SYS::tp(object))

for use in message preparation as necessary. It should be noted that this message will be provided in the current repertoire and encoding. Any need toproduce the message in some other form will need to use the code conversion facilities in the Code section of this library.

#### rune_name

This feature is needed by the internationalisation section of this library when finding resources for the default local culture (not the international default culture!). Thus, for an object of type LIBCHARS, the call

rune_name : RUNES := SYS::rune_name(object)

will produce (in the encoding of the class UNICODE) the word "LIBCHARS".

| Specification Index |  | Language Index |  | Section 8 Index

Comments or enquiries should be made to Keith Hopper . Page last modified: Sunday, 21 May 2000. |