· June 2012 ·

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 []

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))))
Sign in or sign up to add your response.
Featured Programming Job

Front-end Developer - Advertising
New York, NY
Full Time
Search all programming jobs