我有以下clojure代码(尝试从redis写入/获取条目):
(ns hello.core2)
(ns h hello.core2 (:require [taoensso.carmine :as car]))
(def pool (car/make-conn-pool))
(def spec-server1 (car/make-conn-spec))
(defmacro wcar [& body] `(car/with-conn pool spec-server1 ~@body))`
(defn -main
(wcar (car/ping)
(car/set "foo" "bar")
(car/get "foo")))
我收到以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
at clojure.lang.RT.seqFrom(RT.java:487)
at clojure.lang.RT.seq(RT.java:468)
知道我做错了什么?
答案 0 :(得分:6)
问题可能是这样的:
(ns h hello.core2 (:require [taoensso.carmine :as car]))
应该只有一个名称空间声明,如此(所以也移动第一个ns表达式):
(ns hello.core2
(:require [taoensso.carmine :as car]))
答案 1 :(得分:6)
(defn -main ...)
:你忘记了函数-main
的参数向量;它应该是(defn -main [& args] ...)
。