views:

55

answers:

2

Hi,

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"]]
+3  A: 

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.

Rayne
A: 

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]))
John Lawrence Aspden