0
我有以下的Clojure宏:unquoting說法是不正常工作
(defmacro with-model
[ref & body]
`(tx
(let [ds# (when (vector? (first ~body)) (ffirst ~body))
name# (when (vector? (first ~body)) (second (first ~body)))
~ref (model ds# name#)]
(do [email protected]))))
,我試圖用這樣的:
(deftest with-model-test
(with-model sandwich
(let [nodes (-> sandwich .listObjects iterator-seq)]
(is nodes))))
或本:
(deftest with-model-test
(with-model sandwich [*ds* "named-model"]
(let [nodes (-> sandwich .listObjects iterator-seq)]
(is nodes))))
想法是sandwich
現在應該指的是Model
,但我得到一個運行時異常:
Unable to resolve symbol: sandwich in this context
如果我(println ~ref)
宏,我得到的模型實例。如果我(println '~ref)
我得到sandwich
。我應該怎麼做呢?
輝煌。特別爲解構幫助而感到高興。 – tjb1982