Reputation:
This question makes no sense because I'm an idiot and misread the Clojure documentation.
I have something like this:
(defprotocol Foo "doc" [foo bar]
(Foo-bark [foo])
(Foo-meow [foo])
(Foo-other [foo]
... long
multi
line
inline
implementation))
(defprotocol Foo "doc" [foo bar]
(Foo-bark [foo])
(Foo-mewo [foo])
(Foo-other [foo]))
(define Foo-other [foo]
.. long
multi
line
implementation)
Is the above possible? If not, what is the closest I can get to it?
Upvotes: 2
Views: 442
Reputation: 17773
defprotocol can't be used to provide implementations for its functions/methods. You need to use deftype or reify or extend / extend-type (or drop down to classes to do that. For your use-case, you can use extend
to refer to earlier-defined functions to implement a protocol.
Upvotes: 4