Skip to content

Instantly share code, notes, and snippets.

@nathanmarz
Created August 8, 2015 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanmarz/05b564321a46338a3cab to your computer and use it in GitHub Desktop.
Save nathanmarz/05b564321a46338a3cab to your computer and use it in GitHub Desktop.
Protocol functions fail to find extensions is assigned to locals or other var
(defprotocol TestProtocol
(tester [o]))
(let [t tester]
(defn another-tester [o]
(t o)))
(def another-tester2 tester)
(extend-protocol TestProtocol
String
(tester [o] (println "Strings work!")))
(another-tester "A") ;; Error
(another-tester2 "A") ;; Error
(tester "A") ;; Works fine
(let [t tester]
(defn another-tester [o]
(t o)))
(another-tester "A") ;; Works fine
(def another-tester2 tester)
(another-tester2 "A") ;; Works fine
(extend-protocol TestProtocol
Long
(tester [o] (println "Longs work!")))
(another-tester "A") ;; Works fine
(another-tester 3) ;; Error
(another-tester2 3) ;; Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment