Next Previous Up Top Contents Index

8 Dispatch Optimization Coloring in the Editor

8.1 About dispatch optimizations

When you call a generic function in Dylan, the method that will be executed has to be selected from the set of methods defined on that generic function.

The method is selected by comparing the types of the arguments passed in the generic function call to the parameter lists of the methods available; the method whose parameter list is closest to the types of the arguments passed in the call is the one that will be selected. (Note that there may be situations where no one method is more applicable than another, or even where there is no applicable method at all. These situations, which may be detected either at compile time or at run time, signal an error.)

The process of selecting the right method to call is known as method dispatch. The algorithm for selecting a method is described in Chapter 6 of the DRM.

Method dispatch can, in principle, occur entirely at run time; but in some circumstances, the Functional Developer compiler can work out at compile time precisely which method needs to be called, and so optimize away the need for run-time dispatch, making delivered applications faster. Depending on the circumstances, these dispatch optimizations can consist of replacing the generic function call with a direct call to the correct method; replacing the generic function call with a class slot access; or inlining the call completely.


Getting Started with Functional Developer - 31 MAR 2000

Next Previous Up Top Contents Index