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 and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 3 - Page 9 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
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)
       method-body)
     ...

     (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))
     
   self))

A general template of a simulated class with inheritance.

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/colorpoint-class-all-virtual.scmThe functions new-instance, virtual-operations, and others.