Lecture overview -- Keyboard shortcut: 'u'  Previous page: Example of the general class pattern -- Keyboard shortcut: 'p'  Next page: An example of classes with inheritance -- 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 6 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
A general pattern of classes with inheritance

The following shows a template of a function that serves as a subclass of another class

(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 (dispatch message)
       (cond ((eqv? message 'selector) method)
             ...
             (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/object-class.scmThe root of a class hierarchy.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/class-template-functions-inh.scmAccompanying functions for instantiation, message passing, and method lookup.