The last example uses object subtyping to define reusable queues. First the interface:
TYPE
Queue = RECORD head, tail: QueueElem END;
QueueElem = OBJECT link: QueueElem END;
PROCEDURE Insert (VAR q: Queue
x: QueueElem);
PROCEDURE Delete (VAR q: Queue): QueueElem;
PROCEDURE Clear (VAR q: Queue);
Then an example client:
TYPE
IntQueueElem = QueueElem OBJECT val: INTEGER END;
VAR
q: Queue;
x: IntQueueElem;
...
Clear(q);
x := NEW(IntQueueElem, val := 6);
Insert(q, x);
...
x := Delete(q)