I try to define a macro to extract info from a special form of text, [0 => "0\n"]
, actually a list in Clojure.
Now let's say I simply want to get the first
part of it with macro get-input
.
(println (get-input [0 => "0\n"])) ; i.e. 0
The one below works pretty well.
; this works
(defmacro get-input
[expr]
(let [input (first expr)]
input))
But when I use Syntax-Quote, i.e., backquote, things are getting confusing.
Just unquoting the expr
with ~
leads me to this.
While actually I never use the second
part of the expr
, i.e. =>
, but seems it still get evaluated behind.
CompilerException java.lang.RuntimeException: Unable to resolve symbol: => in this context
; this sucks
(defmacro get-input
[expr]
`(let [input# (first ~expr)]
input#))
I want to know what is the difference between first solution and the second one.