我发现 Clojure 1.12 的新 add-lib
没有调用 clojure.core/load-data-readers
(如 clojure.core 在加载时所为),因此如果您引入具有数据读取器的库,就无法使用它们。
从 repl 调用 clojure.core/load-data-readers
无法解决这个问题,因为它改变了 *data-readers*
根值,而这个值已经被 clojure.main/repl 覆盖。
$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.12.0-rc1"} com.github.flow-storm/flow-storm-dbg {:mvn/version "3.17.2"}}}'
Clojure 1.12.0-rc1
user=> *data-readers*
{trace #'flow-storm.api/read-trace-tag, ctrace #'flow-storm.api/read-ctrace-tag, rtrace #'flow-storm.api/read-rtrace-tag, tap #'flow-storm.api/read-tap-tag, tap-stack-trace #'flow-storm.api/read-tap-stack-trace-tag, flow-storm.types/value-ref #'flow-storm.types/make-value-ref, amalloy/ring-buffer #'amalloy.ring-buffer/read-method}
现在使用 add-lib
$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.12.0-rc1"}}}'
Clojure 1.12.0-rc1
user=> (add-lib 'com.github.flow-storm/flow-storm-dbg {:mvn/version "3.17.2"})
[...]
user=> *data-readers*
{}
user=> (#'clojure.core/load-data-readers)
{trace #'flow-storm.api/read-trace-tag, ctrace #'flow-storm.api/read-ctrace-tag, rtrace #'flow-storm.api/read-rtrace-tag, tap #'flow-storm.api/read-tap-tag, tap-stack-trace #'flow-storm.api/read-tap-stack-trace-tag, flow-storm.types/value-ref #'flow-storm.types/make-value-ref, amalloy/ring-buffer #'amalloy.ring-buffer/read-method}
user=> *data-readers*
{}
通过添加库引入数据读取器的唯一方法是启动一个子 repl
clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.12.0-rc1"}}}'
Clojure 1.12.0-rc1
user=> (add-lib 'com.github.flow-storm/flow-storm-dbg {:mvn/version "3.17.2"})
[...]
user=> (binding [*data-readers* (#'clojure.core/load-data-readers)] (clojure.main/repl))
user=> *data-readers*
{trace #'flow-storm.api/read-trace-tag, ctrace #'flow-storm.api/read-ctrace-tag, rtrace #'flow-storm.api/read-rtrace-tag, tap #'flow-storm.api/read-tap-tag, tap-stack-trace #'flow-storm.api/read-tap-stack-trace-tag, flow-storm.types/value-ref #'flow-storm.types/make-value-ref, amalloy/ring-buffer #'amalloy.ring-buffer/read-method}
这不会与 nrepl 工具配合工作。