13.9 Protocol design

We can now define the angle library as another client of the sixty-unit library. The interface of the angle library consists of the classes <angle> and <directed-angle>, and the say method. Uh-oh! We want that say method to be another method on the say generic function defined by the time library, so that a client of the time and angle libraries sees a single generic function, say, that applies to either times or angles. This situation illustrates the value of putting a lot of thought into designing our protocols before we get too deep into an implementation. The say generic function is a separate protocol that could apply to many classes in our system. To permit separate libraries to add methods to a Dylan generic function, the module defining the protocol (that is, the module defining the generic function) needs to be defined first, in a separate, common library. Other libraries then use this component library to define their particular implementation of the protocol.

To create the say protocol, we define a library and implementation file as shown in Sections 13.9.1 through 13.9.4.