Predicate Dispatch¶
A guarded method-selection mechanism that tests arguments for applicability and, in its formal form, orders applicable implementations by predicate implication.
Core Idea¶
Predicate dispatch selects an implementation of a generic operation using guards on the actual arguments of a call. In the original formal model, a guard that logically implies another is more specific and can override it. This extends receiver-type and multiple-type dispatch to conditions involving values, state and relationships between arguments. Implementations differ: JPred restricts its guards so static checks can establish coverage and resolve overlap; Raku `where` multis are related but may use declaration order rather than formal implication.[ref-35186a5d2bdc][ref-3dcfd4affeaa][^ref-1bf4133d3392]
Scope of Application¶
The mechanism is useful when cases depend on more than argument class. In Millstein's one.world discovery-service rewrite, JPred separated event handlers by state/event, null-entry and capacity guards. The reported conversion of 20 methods exposed an ambiguity/redundancy, three potential nonexhaustive cases and removed 11 unprotected casts. These are case-study findings, not universal guarantees. Guarded multi syntax in other languages may have different precedence rules.[ref-3dcfd4affeaa][ref-1bf4133d3392]
Clarity¶
In a constructed `handle(record)` lattice, guards `true`, `ready`, `highUrgency` and `ready && highUrgency` all apply to a joint-state record. The conjunction implies both single-property guards and wins under implication ordering. Remove it and the two specialized guards overlap incomparably; source-order matching is a different policy.
Manages Complexity¶
Guards localize the cases instead of embedding a large conditional ladder in one method. They also make extension possible where the language supports it. Overlap becomes the central risk: adding one guarded implementation can change whether calls have a unique winner.
Abstract Reasoning¶
First determine which guards hold for the current arguments. Then determine which of those guards outrank the others under the actual language rule. In the formal model, implication supplies that relation. Check both coverage (some guard applies) and coherence (one method wins); do not assume that any executable guard belongs to a predicate language whose implication can be decided statically.[ref-35186a5d2bdc][ref-3dcfd4affeaa]
Knowledge Transfer¶
The reusable pattern is guarded alternatives plus an explicit selection order. Predicate dispatch applies it specifically to method or function invocation; generic policy rules or if-branches are not automatically the same mechanism.
[^ref-35186a5d2bdc]: Ernst, Kaplan and Chambers, original predicate-dispatch theory (1998). [^ref-3dcfd4affeaa]: Millstein, original JPred paper (2004). [^ref-1bf4133d3392]: Official Raku multi-dispatch documentation.
Relationships to Other Abstractions¶
Current abstraction Predicate Dispatch Domain-specific
Parents (1) — more general patterns this builds on
-
Predicate Dispatch presupposes Selection Prime
Each predicate-dispatch invocation differentially admits and chooses applicable methods under guarded selection.
Hierarchy path (1) — routes to 1 parentless root
- Predicate Dispatch → Selection
Neighborhood in Abstraction Space¶
Predicate Dispatch sits in a sparse region of the domain-specific corpus (65th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.
Family — Type Systems & Functional Constructs (18 abstractions)
Nearest neighbors
- Modus ponens — 0.85
- Long Parameter List — 0.85
- Command–query separation — 0.84
- Denying the Antecedent — 0.84
- Principle of Explosion — 0.84
Computed from structural-signature embeddings · 2026-10-08