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'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Lecture 8 - Page 8 : 11
Functional Programming in Scheme
Object-oriented programming in Scheme
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.

y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/includes/object-class.scmA simulation of the root of a class hierarchy.


y:/Kurt/Files/courses/prog3/prog3-03/sources/notes/includes/class-template-functions-inh.scmAccompanying functions for instantiation, message passing, and method lookup.