以下编码按预期执行,但最终给出<代码>NullPointerException。 我在这里做了什么错误?
(ns my-first-macro)
(defmacro exec-all [& commands]
(map (fn [c] `(println "Code: " ~c " => Result: " ~c)) commands))
(exec-all
(cons 2 [4 5 6])
({:k 3 :m 8} :k)
(conj [4 5 d] e f))
; Output:
; Clojure 1.2.0-master-SNAPSHOT
; Code: (cons 2 [4 5 6]) => Result: (2 4 5 6)
; Code: ({:k 3, :m 8} :k) => Result: 3
; Code: (conj [4 5 d] e f) => Result: [4 5 d e f]
; java.lang.NullPointerException (MyFirstMacro.clj:0)
; 1:1 user=> #<Namespace my-first-macro>
; 1:2 my-first-macro=>
http://paste.pocoo.org/show/237463/“rel=“nofollow noretinger”here。