next up previous contents
Next: Procedural Activation of Up: ClassesInstances, and Previous: Classes and Instances

Message Passing

 

In this section I will discuss the activation of methods via so-called message passing. The possible method selectors of objects of class class-name are enumerated in the procedure self of the class. If we, for instance, want to activate my-method in instance , it can be done in the following way.

((instance message) actual-parameter ...)

provided that message is mapped to my-method in the procedure self .gif Again, I prefer not to use ``the raw procedure call syntax''. In order to amplify the message sending metaphor, I prefer the following equivalent form.

(send instance message actual-parameter ...)

The procedure send can be implemented in the following simple way:

 

(define (send object message . args)
  (let ((method (object message)))
    (cond ((procedure? method) (apply method args))
          (else (error "Error in method lookup " method)))))


Kurt Noermark
Wed Mar 6 10:30:05 MET 1996