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

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

(define (class-name construction-parameters)
 (let ((instance-var init-value)
        ...)
     
   (define (method parameter-list)
     method-body)

   ...
     
   (define (self message)
     (cond ((eqv? message selector) method)
	   ...
             
	   (else (error "Message not understood" message))))
     
   self))

A general template of a simulated class. construction-parameters are typically transferred to the let construct, which we want to play the role as instance variables. Next comes explicitly defined methods, and last is the object handle called self . Notice that the value returned by the class is the value of self - the object handle.

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