2024 Cljure调查!中分享您的看法

欢迎!欲了解更多关于该平台的信息,请参阅关于页面

+4 votes
Cljure
已关闭

我发现Cljure 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}

现在用

$ 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*
{}

我认为用add-lib引入数据读取器唯一的办法是启动一个子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工具一起使用。

以注释关闭: 将在1.12.0-rc2中发布

1 答案

0 votes
...