The interface mechanism commonly used in OLE Automation deserves particular mention. As we have seen, server components can expose their services to clients through named interfaces: a simple painting server might offer a drawing interface called IPaint, while a word processor might offer access to its thesaurus through an interface called IThesaurus, and access to its indexing tools through an interface called IIndex.
But in Automation it is common to use a different means of exposing services to clients. Rather than defining named interfaces, Automation servers implement a dispatch interface or dispinterface protocol, where clients access COM methods through a dispatching mechanism instead of on a call-by-name basis.
The dispinterface protocol is defined by the standard COM interface IDispatch. This interface defines four COM methods: Invoke, GetTypeInfo, GetIDsOfNames, and GetTypeInfoCount. It also inherits from IUnknown, as all COM interfaces do, and so must provide implementations for the QueryInterface, AddRef and Release methods.
Every other COM method that a server defines for the dispinterface has its own identifier, called a dispatch identifier or DISPID. Rather than call these methods using a name, clients call Invoke and pass it the DISPID of the method they want to invoke.
As well as COM methods, dispinterfaces can also have properties. Properties are values that can be retrieved or set, just like slots in Dylan classes. Like the methods in a dispinterface, properties are accessed using IDispatch's standard method Invoke.
Functional Developer's high-level interface to Automation is the OLE-Automation library. This library exports the Dylan class <simple-dispatch>, which represents the COM interface IDispatch.
You can define dispinterfaces of your own by defining a subclass of <simple-dispatch>. You can then define dispatch methods for your dispinterface by writing Dylan methods on your subclass of <simple-dispatch>. Because <simple-dispatch> is a subclass of <IUnknown>, it inherits the implementations of the three IUnknown methods.
You can define properties for your dispinterface simply by adding slots to your subclass definition.