Polymorphic dispatch
Polymorphic dispatch is runtime selection of an operation implementation based on a call's arguments, function value, or context.
Data-Oriented Programming: Reduce software complexity
A dispatch function is a function that defines a multimethod's signature, validates its arguments, and emits a value used to select an implementation.
- How it is used
- Uses dispatch functions to separate multimethod call signatures and selection logic from method implementations.
- How deep it goes
- Explains signatures, validation, single, multiple, and dynamic dispatch with JavaScript examples, but does not develop their implementation machinery.
- Examples
- Demonstrates animal greetings selected by type, animal-language pairs, and animal type combined with name length.
- What you can do after
- Build multimethods whose behavior varies by one argument, several arguments, or runtime-derived values.
Read how Data-Oriented Programming: Reduce software complexity explains polymorphic dispatch →
Clojure: The Essential Reference
A dispatch function is a callable operation that selects and invokes an implementation based on an argument's dispatch value.
- How it is used
- Selects behavior for data-driven operations and supports flexible polymorphism beyond type-based method selection.
- How deep it goes
- Defines dispatch functions, implementations, hierarchies, ambiguity resolution, extension, removal, inspection, and failure behavior.
- Examples
- Demonstrates expression evaluation, custom operation hierarchies, runtime extension, method removal, ambiguity resolution, recursion, and exceptions.
- What you can do after
- Build it from scratch using defmulti, defmethod, custom hierarchies, default methods, and protocol extensions.
Read how Clojure: The Essential Reference explains polymorphic dispatch →
Related concepts
- multiple dispatchused by · Multiple dispatch is a method-selection mechanism that chooses an implementation based on the types of multiple arguments.
- multimethodused by · A multimethod is a dispatch mechanism that selects an implementation by applying a dispatch function to multiple arguments, often using their runtime types or values.
- defprotocolproduced by · defprotocol is a Clojure macro that defines a protocol interface supporting dynamic dispatch independently of Java class inheritance.
- contractcontrasts with · An API contract is a specification of the operations, data, and behavioral expectations that govern interactions between software components.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

