gpt4 book ai didi

asynchronous - Clojure core.async 和 clojure.core 命名空间元素似乎发生了冲突

转载 作者:行者123 更新时间:2023-12-01 01:51:54 26 4
gpt4 key购买 nike

我正在尝试修改 Cursive ,Clojure 语言的 Intellij 插件。我通过 Lein 导入了一个非常标准的新应用程序,现在正试图与一些 core.async构造。

这是项目定义:

(defproject app "0.1.0-SNAPSHOT"
:description "Clojure project illustrating basic core.async constructs"
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]])

来源:

(ns app.core)

(require '[clojure.core.async :as async :refer :all])

(let [c (chan 10)]
(>!! c "hello")
(println (<!! c))
(close! c))

基本的 Clojure 构造工作没有任何问题。但是在 Lein 中添加 core.async 依赖项后,每次我尝试运行一段代码时,都会出现这些警告:

WARNING: partition-by already refers to: #'clojure.core/partition-by in namespace: app.core, being replaced by: #'clojure.core.async/partition-by
WARNING: map already refers to: #'clojure.core/map in namespace: app.core, being replaced by: #'clojure.core.async/map
WARNING: into already refers to: #'clojure.core/into in namespace: app.core, being replaced by: #'clojure.core.async/into
WARNING: reduce already refers to: #'clojure.core/reduce in namespace: app.core, being replaced by: #'clojure.core.async/reduce
WARNING: partition already refers to: #'clojure.core/partition in namespace: app.core, being replaced by: #'clojure.core.async/partition
WARNING: take already refers to: #'clojure.core/take in namespace: app.core, being replaced by: #'clojure.core.async/take
WARNING: merge already refers to: #'clojure.core/merge in namespace: app.core, being replaced by: #'clojure.core.async/merge

这似乎是某种命名空间冲突。

有没有简单的方法可以解决这个问题?

最佳答案

namespace 存在的原因是为名称提供上下文,以便它们可以被重用。这只是一个例子。通过使用 :refer :all 你试图引入许多与 clojure.core 函数冲突的函数。我通常只将 core.async 的更多语法元素的一个子集带入我的 ns 并为其余部分创建一个别名:

(require '[clojure.core.async :as async :refer [>! <! >!! <!! go]])

大多数重叠的名称现在实际上已被弃用,并且将来会被删除,因为传感器不再需要它们。例如,您将使用 Clojure 1.7 中的 clojure.core.take 传感器创建一个 chan,而不是使用 clojure.core.async.take。

关于asynchronous - Clojure core.async 和 clojure.core 命名空间元素似乎发生了冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26173582/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com