-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
clojure.clj
43 lines (34 loc) · 1.3 KB
/
clojure.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(ns methodical.impl.combo.clojure
"Simple method combination strategy that mimics the way vanilla Clojure multimethods combine methods; that is, to say,
not at all. Like vanilla Clojure multimethods, this method combination only supports primary methods."
(:require
[clojure.core.protocols :as clojure.protocols]
[methodical.interface]
[methodical.util.describe :as describe]
[pretty.core :as pretty])
(:import
(methodical.interface MethodCombination)))
(set! *warn-on-reflection* true)
(comment methodical.interface/keep-me)
(deftype ClojureMethodCombination []
pretty/PrettyPrintable
(pretty [_]
'(clojure-method-combination))
Object
(equals [_ another]
(instance? ClojureMethodCombination another))
MethodCombination
(allowed-qualifiers [_]
#{nil}) ; only primary methods
(combine-methods [_ [primary-method] aux-methods]
(when (seq aux-methods)
(throw (UnsupportedOperationException. "Clojure-style multimethods do not support auxiliary methods.")))
primary-method)
(transform-fn-tail [_this _qualifier fn-tail]
fn-tail)
clojure.protocols/Datafiable
(datafy [this]
{:class (class this)})
describe/Describable
(describe [this]
(format "It uses the method combination `%s`." (.getCanonicalName (class this)))))