I'd like to construct a ClojureScript macro (executed/compiled via Clojure) that informs it's construction of a return form based on the static, compile-time metadata of a ClojureScript var argument.
I understand it is possible to access compile-time, static var metadata from ClojureScript code (using (meta (var varsym)); see this post). But is this data accessible to the compilation process in such a way that we could access it from a macro?
Here's a rough sketch of what I'd like to do (and the question is really how you'd write get-meta-for-varsym below):
;; executed/compiled in clj, targeting cljs
(defmacro themacro
[varsym & args]
(let [var-meta (get-meta-for-varsym varsym)
return-form (compile-return-form-from-metadata var-meta args)]
return-form))
Vars at runtime, but uses bare Javascript variables instead. - Nathan Davis