例子:
(defprotocol Foo (foo [x]))
(extend-protocol Foo Long (foo [x] (inc x)))
;; This is the way that I know how to do it... is there a better way?
(def long-foo (-> #'foo meta :protocol deref :impls (#(get % Long)) :foo))
我对此感兴趣,以优化将多次调用的任务,每次调用都需要很短的时间。为了防止在我的特定情况下进行额外的函数调用,我已经切换extend-protocol
到。extend