Clojure - How to make my macro expand before system macros?

前端 未结 3 458
我在风中等你
我在风中等你 2021-01-12 06:57

If I do, for example:

(defmacro qqq [] \'(toString [this] \"Qqq\"))
(reify Object (qqq))

it fails because of reify sees

3条回答
  •  误落风尘
    2021-01-12 07:22

    There is a reader-macro to evaluate things at read-time (before macro-expansion time)..

    (defn qqq [] '(toString [this] "Qqq"))
    (reify Object #=(qqq))
    

    I've never seen this done in "real" code, and I think most people would consider it a hack, but it's there if you need it.

提交回复
热议问题