How OOP Works

Sending a message is just an indirect procedure call.

The send function determines the class of the object to which the message was sent. Then it looks up the name of the method that corresponds to that class and the selector of the message (the method is often named class -selector), makes the arguments into a function call, and calls the method function.

The message (send tree 'draw x y size) may turn into:

(atom-draw tree x y size)
(pair-draw tree x y size)
(null-draw tree x y size)
(mobile-draw tree x y size)
(box-draw tree x y size)
(triangle-draw tree x y size)

depending on the class of the tree.

Contents    Page-10    Prev    Next    Page+10    Index