Introduction to OOP: Chapter 21 : Implementation [next] [previous] [audio] [real] [text]

Dispatch Tables

In languages without static typing it is not practical to use a virtual table, since such a table would need to encode all methods, not simply those in a given class hierarchy.

An alternative technique uses a pointer to a list of selector/method pairs.

When a method is invoked, a run-time search is performed to match the method being called with the list of known selectors, until an appropriate method is found.

In Objective-C the messages

[ neighbor checkrow: row column: column ]

is translated into

objc_msgSend(neighbor, "checkrow:column:", row, column)
Intro OOP, Chapter 21, Slide 10