(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 "Undefined message" 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.
|