如何在 clojure 1.2 下包含 clj-time 和 clojure.contrib?

发布于 2024-09-25 10:29:24 字数 535 浏览 4 评论 0原文

由于 1.2 中引入了新协议,我尝试将项目从 clojure 1.1 迁移到 1.2。但是当我尝试 :use clojure-contrib.duck-streams 时,我收到有关 clojure.core 中已存在的“spit”的警告。 clj-time.core 和 clojure.core 中也存在“extend”同样的问题。

谁能解释一下解决这些愚蠢错误的最优雅的方法是什么?

顺便说一句:来自我的 project.clj

 :dependencies [[org.clojure/clojure "1.2.0"]
                [org.clojure/clojure-contrib "1.2.0"]
                [clojure-csv/clojure-csv "1.1.0"]
                [org.shxiao/clojureql "1.0.0"]
                [clj-time "0.1.0-SNAPSHOT"]]

I tried to migrate a project from clojure 1.1 to 1.2 because of the new protocols introduced in 1.2. But when I try to :use clojure-contrib.duck-streams I get a warning about 'spit' which already exists in clojure.core. The same problem with clj-time.core and 'extend' which also exists in clojure.core.

Can anyone explain what would be the most elegant way around these stupid errors?

BTW: from my project.clj:

 :dependencies [[org.clojure/clojure "1.2.0"]
                [org.clojure/clojure-contrib "1.2.0"]
                [clojure-csv/clojure-csv "1.1.0"]
                [org.shxiao/clojureql "1.0.0"]
                [clj-time "0.1.0-SNAPSHOT"]]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风和你 2024-10-02 10:29:24

您可以通过将 (:refer-clojure :exclude [extend]) 放入 (ns ..) 中来消除扩展警告(或错误?)。不过,我不久前提交了一个补丁来解决这个问题。我猜他们从来没有为它发布过新的快照。

至于duck-streams位,这是因为spit曾经位于duck-streams中,但现在位于clojure.core中。查看 clojure.java.io。 duck-stream 的大部分功能在 Clojure 1.2 中达到了顶峰。如果您不想使用 clojure.java.io,则吐出警告相当无害,但可以通过在使用 clojure.contrib.duck-streams(也是 clojure.contrib.io)时简单地排除它来摆脱它。现在)。

(ns foo (:use [clojure.contrib.duck-streams :exclude [spit]]))

以下是 clojure.java.io 的一些 API 文档: http://clojuredocs.org/Clojure %20Core/clojure.java.io。在撰写本文时,http://clojure 上似乎没有任何相关文档。 github.com/clojure/。不知道为什么。

You can get rid of the extend warning (or error?) by putting (:refer-clojure :exclude [extend]) in your (ns ..). I submitted a patch to fix that a while back though. Guess they never put out a new snapshot for it.

As for the duck-streams bit, it's because spit used to be in duck-streams, but is now in clojure.core. Check out clojure.java.io. Most of duck-stream's functionality was culminated there in Clojure 1.2. If you don't want to use clojure.java.io, the spit warning is fairly harmless, but can be gotten rid of by simply excluding it when you use clojure.contrib.duck-streams (which is also clojure.contrib.io now).

(ns foo (:use [clojure.contrib.duck-streams :exclude [spit]]))

Here are some API docs for clojure.java.io: http://clojuredocs.org/Clojure%20Core/clojure.java.io. At the time of this writing, there don't appear to be any docs for it up at http://clojure.github.com/clojure/. No clue why.

只有影子陪我不离不弃 2024-10-02 10:29:24

虽然其中一些信息是正确的,但 duck-streams 已从 contrib 中删除,并且在 1.2 之后将不再存在。无论如何,duck-streams 中确实没有什么是您在核心 Clojure 中无法完成的。

While some of this information is correct, duck-streams has been removed from contrib and will no longer be around after 1.2. There really isn't much in duck-streams that you can't already do in core Clojure anyways.

忘年祭陌 2024-10-02 10:29:24

导入除导致冲突的函数之外的所有内容。然后 spit 将引用已引入 clojure.core 的版本,这可能是首选版本

(use '[clojure.contrib.duck-streams :exclude 'spit])

ns 宏形式为:

(ns foo (:use [clojure.contrib.duck-streams :exclude 'spit]))

Import everything except the function causing the clash. Then spit will refer to the version that's been brought into clojure.core, which is probably the preferred version

(use '[clojure.contrib.duck-streams :exclude 'spit])

The ns macro form is:

(ns foo (:use [clojure.contrib.duck-streams :exclude 'spit]))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文