Lecture overview -- Keyboard shortcut: 'u'  Previous page: A general pattern of classes with inheritance -- Keyboard shortcut: 'p'  Next page: The interpretation of self -- 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 7 : 43

An example of classes with inheritance
We sketch one of the favorite toy specializations of Point - ColorPoint
(define (color-point x y color)
 (let ((super (new-part point x y))
       (self 'nil))
   (let ((color color))
       
     (define (get-color)
       color)

     (define (type-of) 'color-point)
       
     (define (dispatch message)
       (cond ((eqv? message 'get-color) get-color)
             ((eqv? message 'type-of) type-of)
             (else (method-lookup super message))))
       
     (set! self dispatch)
   )
     
   self))
colorpoint-class-all.scm
Class Point - A subclass of object - with a new method point-info.
colorpoint-class-all.scm
All necessary stuff to play with ColorPoint.
color-point-dialogue
A sample construction and sample dialogue with ColorPoint.