2
我通過一些實例的Clojure從工作braveclojure:爲什麼這個clojure函數不能執行?
http://www.braveclojure.com/writing-macros/
目前我想基本上執行此
(ns turtle (:use clojure.pprint))
(def criticisms {:good "good code:" :bad "bad code:"})
(defn criticize-code
[[critkey code]]
`(println (~critkey criticisms) (quote ~code)))
(defmacro code-critic
[code-evaluations]
`(do [email protected](map criticize-code code-evaluations)))
(println "executed code critic")
(code-critic {:good (+ 1 1) :bad (1 + 1)})
(println "code critic expansion")
(pprint (macroexpand '(code-critic {:good (+ 1 1) :bad (1 + 1)})))
;why isn't this executing?
(println "criticize code expansion")
(criticize-code [:good '(+ 1 1)])
,我可以驗證批評代碼返回正確格式的代碼通過println
;但我實際上無法執行它......有人可以告訴我我做錯了什麼嗎?
謝謝!