Welcome! Please see the About page for a little more info on how this works.

0 votes
in Macros by


I have following synthetic macro receiving function expression as argument:

(defmacro func-macro [f]
  `(def x ~f))

Macroexpansion gives me:

( macroexpand-1 `(func-macro (fn [x] x)))
  (def runtime.repl/x (clojure.core/fn [runtime.repl/x] runtime.repl/x))

If i execute this code form in REPL then i ll get an error because function has namespace qualified symbol runtime.repl/x as argument.

(runtime.repl/x) - failed: Extra input at: [:fn-tail :arity-1 :params] spec: :clojure.core.specs.alpha/param-list
runtime.repl/x - failed: vector? at: [:fn-tail :arity-n :params] spec: :clojure.core.specs.alpha/param-list

But if i am calling this macro in REPL then all things work!

( (func-macro (fn [x] x)) 100)

Why runtime.repl/x is OK for function definition if i am calling macro in REPL?



1 Answer

0 votes


(macroexpand-1 '(func-macro (fn [x] x)))

with a normal single quote instead. You don't need the backtick here.