开发者

How to include clj-time and clojure.contrib under clojure 1.2?

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:

开发者_JS百科
 :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"]]


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.


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.


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]))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜