Skip to content

Instantly share code, notes, and snippets.

@moxaj
Last active May 16, 2018 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moxaj/82d9ac9cc79ca17231afdd33c7b91274 to your computer and use it in GitHub Desktop.
Save moxaj/82d9ac9cc79ca17231afdd33c7b91274 to your computer and use it in GitHub Desktop.
(set! *warn-on-reflection* true)
(defn apply-fn1 [x f arg]
;; apply f
x)
(defmacro apply-fn2 [x f arg type]
(vary-meta (do
;; apply f
x)
assoc :tag type))
(defn foo1 [x]
(-> x
(apply-fn1 nil nil)
(.length))) ;; Reflection warning!
(defn foo2 [x]
(-> x
(apply-fn2 nil nil String)
(.length))) ;; No reflection warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment