19.10 Additions to the Libraries

Unlike the Generic extensions, those for OOM-2 require some library support. That for exceptions parallels the one in the base language; coroutines requires one additional procedure, and garbage collection also has a library.

19.10.1 Exceptions

OOM-2 extensions to the base language define four new exceptions. Detection of the first three is mandatory, but detection of the last one is optional. They are:

1. emptyException
raised whenever an attempt is made to access an object via an empty reference

2. abstractException
raised whenever an attempt is made to call an abstract method

3. guardException
raised if there is no match on the list of selections (possibly due to an empty reference) and no ELSE

4. immutableException
an implementation may choose to raise this if there is an attempt to change an immutable entity.

In addition, there is a new system module, which behaves as if it had the following definition:


(* Provides facilities for identifying exceptions of the extended language *)

  M2OOExceptions =
    (emptyException, abstractException, immutableException, guardException);

PROCEDURE M2OOException (): M2OOExceptions;
  (* If the current coroutine is in the exceptional execution state because
     of the raising of an exception of the language extensions, returns the
     corresponding enumeration value, and otherwise raises an exception. *)

  (* If the current coroutine is in the exceptional execution state because
     of the raising of an exception of the language extensions, returns
     TRUE, and otherwise returns FALSE. *)


The entities of this system module behave in exactly the same way as do those of the module M2EXCEPTION described in section 10.2.1 except that they act on the OOM-2 exception enumeration instead of that of the base language.

19.10.2 Coroutines

The module COROUTINES (see the chapter on that subject) in the base standard has one procedure added to provide support for OOM-2. It is

  (* Declare that the coroutine identified by cr has reached the end of its lifetime. *)

The procedure DISPOSECOROUTINE is used to inform the garbage collector that the coroutine of the actual parameter has reached the end of its lifetime. The garbage collector takes this to mean that all the traced variables in that coroutine have become defunct and may be collected.

19.10.3 The Module Garbage Collection

In some implementations it may be possible to turn garbage collection off and on, or to force it to take place at specified points in a program when it is convenient, rather than leave it up to automatic routines. Thus, the procedures of the following module may do something, but only if the implementation allows this. Their semantics are described in the comments and need no further explanation.


(* Provides facilities for controlling the garbage collector. *)

PROCEDURE IsCollectionEnabled (): BOOLEAN;
  (* If garbage collection is enabled then returns TRUE and otherwise returns FALSE. *)

PROCEDURE CollectionEnable (on: BOOLEAN);
  (* If on is TRUE then enable garbage collection; otherwise if on is FALSE and garbage 
     collection can be disabled then disable garbage collection. *)

PROCEDURE ForceCollection;
  (* If garbage collection can be forced then force it else do nothing. *)