class-template-functions-inh.scm - Accompanying functions for instantiation, message passing, and method lookup. | Lecture 8 - slide 8 : 11 Program 2 |
(define (new-instance class . parameters) (apply class parameters)) (define (new-part class . parameters) (apply class parameters)) (define (method-lookup object selector) (cond ((procedure? object) (object selector)) (else (error "Inappropriate object in method-lookup: " object)))) (define (send message object . args) (let ((method (method-lookup object message))) (cond ((procedure? method) (apply method args)) ((null? method) (error "Message not understood: " message)) (else (error "Inappropriate result of method lookup: " method)))))