Lecture overview -- Keyboard shortcut: 'u'  Previous page: The interpretation of self -- Keyboard shortcut: 'p'  Next page: An example of virtual methods -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Simulation of other Paradigms and Continuations - slide 9 : 43

A general pattern of a class hierarchy with virtual methods
The following shows a template of a function that serves as a subclass of another class - now with virtual methods
(define (class-name parameters)
 (let ((super (new-part super-class-name some-parameters))
       (self 'nil))
   (let ((instance-variable init-value)
     (define (method parameter-list)

     (define (set-self! object-part)
         (set! self object-part)
         (send 'set-self! super object-part))
     (define (dispatch message)
       (cond ((eqv? message 'selector) method)
             ((eqv? message 'set-self) set-self!)
             (else (method-lookup super message))))
     (set! self dispatch))
The functions new-instance, virtual-operations, and others.