Amalomna will answer questions why . For the part of making it work you will need to use eval .
Instead of ($ content h) use
(eval `($ content ~h))
Another explanation of why this is so is based on what operations the macro performs at compile time and what it does at run time (that is, what code it emits). The following is an example to clarify the situation.
(def user "ankur") (defmacro do-at-compile [v] (if (string? v) `true `false)) (defmacro do-at-runtime [v] `(if (string? ~v) true false)) (do-at-compile "hello") ;; => true (do-at-compile user) ;; => false, because macro does perform the check at compile time (do-at-runtime "hello") ;; => true (do-at-runtime user) ;; => true
The $ macro performs calculations on the second parameter passed at compile time and therefore does not work in your particular case.
source share