page 2  (16 pages)
to previous section1
3to next section


Most object oriented languages today offer a single semantics for the application of operations to objects: that of procedures. Even though procedures, usually called methods, may be late bound to receiving objects, it is typically the case that the environment where the application takes place has its execution suspended while the applied operation is executing, and that control data such as return addresses, dynamic links and the like must be saved on the execution stack in order to allow for control flow.

Other semantics may also be useful. For example, in object oriented languages for the construction of applications dealing with graphical user interfaces, where users asynchronously interfere with the execution, the sending of a message to an object does not need to block the execution of the environment where the operation was applied. In this case the message is usually placed on a queue, to be eventually processed by a corresponding message handler. The Windowsfi operating system from Microsoft [10] is a software platform where this semantics is available, though at a very low level. In the TOOL programming system [2, 12], to be described in some detail below, the asynchronous behavior of objects can also be declared in classes [3].

As another example, consider exception handling. Here it may be convenient to attach exceptional behavior to objects, by placing, within classes, exception handlers to be executed when local handlers for raised exceptions are not available. Such class exception handlers would then provide an intermediate handling level, between that of local handlers and that associated with the call to the raising operation. An exception handling mechanism along these lines has been proposed in [4].

In this paper we discuss two situations, in object oriented programming, where the semantics of coroutines is useful: in the implementations of loop iterators and of dynamic data structure navigators. In both cases the receiving object is a loop control object. Iterators are applied to produce, outside of the loop environment, the next value for this loop control object; navigators are applied to indicate, outside of the loop environment, the next element in a dynamic data structure. This is clearly advantageous to the understanding of programs, since the size of the loop's body is reduced accordingly. Moreover, it would be nice to be able