Type hints in clojure macros
Type hints should be added to symbols. Here's how to do it for function's return type:
(defmacro defthreadlocal [name & body]
`(def ~(with-meta name {:tag ThreadLocal})
(proxy [ThreadLocal] []
(initialValue []
~@body))))
And here's how to do it for args:
(defmacro declare-first-char []
(let [s (gensym)]
`(defn first-char [~(with-meta s {:tag String})]
(.charAt ~s 0))))
Written by Nikita Prokopov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Clojure
Authors
Related Tags
#clojure
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#