liveBook · Manning

Polymorphic dispatch

Polymorphic dispatch is runtime selection of an operation implementation based on a call's arguments, function value, or context.

How 2 Manning books explain it

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

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.