Skip to content

Instantly share code, notes, and snippets.

@bmillare
bmillare / anarchy.clj
Created September 6, 2012 19:17 — forked from ctford/anarchy.clj
Simple system for plural dispatch
(ns dj.plurality)
(defmacro defplural-body [pluralfn-name arg-list & resolver-body]
`(def ~pluralfn-name (let [implementations# ~(if (resolve pluralfn-name)
`(atom (or @(:dj.plurality/implementations (meta ~pluralfn-name))
[]))
`(atom []))]
(with-meta (fn ~pluralfn-name ~(into [] (rest arg-list))
(let [~(first arg-list) @implementations#]
~@resolver-body))