Talks
Events

Predicate Dispatch

David Nolen at Clojure Conj 2011

When designing functions that can leverage more than the type of the first argument, the Clojurian reaches for multimethods. Yet after some experience, he/she might realize that multimethods have considerable limitations, particularly the closed nature of the dispatch function itself. How can we fulfill the promise of open extension? Predicate dispatch as described by Craig Chambers and Weimin Chen seems promising, but their implementation hardwires many important details. By leveraging the literature around high performance pattern matching compilation as found in Standard ML, OCaml, and Haskell and by driving the compilation with a logic engine, we can achieve a fully open predicate dispatch system with considerable performance gains over multimethods.