views:

124

answers:

2

This page introduces a lot of clojure libraries. And this page also comments to consider using the clojure-contrib.

  • Why the clojure-contrib.jar is different in size? The leiningen's clojure-contrib-1.2.0-beta1.jar is 479.2KB in size, but the conjure-contrib.jar that I downloaded from Programming Clojure is 2.9MB. As I explained in here. Does the clojure-contrib.jar is not standardized as of today?
  • Should the libs in the page be a part of clojure-contrib? If so, why leiningen's clojure-contrib.jar doesn't have the str-utils or repl-utils? As a result, I can't run (use 'clojure.contrib.str-utils) with leiningen (lein swank) in emacs/slime.
  • What's the meaning of clojure.contrib.A as is shown in the page? As far as I know, (use 'a.b) lets clojure to find CLASSPATH/A/B.clj to load and do refer as is explained in Programming Clojure book page 18. Is this saying that the A clj file in /clojure/contrib directory or inside the clojure-contrib.jar?
  • How to download, install, and setup the libs in the page?

Added

After updating leiningen, I checked that (use 'clojure.contrib.str-utils) works fine. But, (use 'clojure.contrib.repl-utils) gives me the following error.

  [Thrown class java.lang.IllegalStateException]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: clojure.lang.Namespace.warnOrFailOnReplace(Namespace.java:88)
  1: clojure.lang.Namespace.reference(Namespace.java:110)
  2: clojure.lang.Namespace.refer(Namespace.java:168)
  3: clojure.core$refer.doInvoke(core.clj:3288)
  4: clojure.lang.RestFn.invoke(RestFn.java:411)
  5: clojure.lang.AFn.applyToHelper(AFn.java:163)
  6: clojure.lang.RestFn.applyTo(RestFn.java:133)
  7: clojure.core$apply.invoke(core.clj:542)
  8: clojure.core$load_lib.doInvoke(core.clj:4781)
  9: clojure.lang.RestFn.applyTo(RestFn.java:143)
 --more--

(require 'clojure.contrib.repl-utils) work, and I can use (clojure.contrib.repl-utils/show #{}), but (refer 'clojure.contrib.repl-utils) gives me an error.

And here are some more question.

  • Why (use '..repl-utils) causes an error, whereas str-utils does not? What's the difference bewteen the two libs?
+1  A: 

I'm not sure what you mean by standardized, but contrib doesn't make backwards breaking changes without good reason. Some things are occasionally moved to core, if they're sufficiently important -- I seem to recall sequence functions doing that, and likely the string functions that you're thinking of.

Re: Leiningen: a new version just came out. In any case, it sounds like you might have a version conflict.

Regarding the classpath: the source of many unpleasant problems until you get used to it (or it was for me). It could be either of the things you mention, given the context, we're almost certainly talking about clojure-contrib.jar.

To download etc. there are various methods. The easiest method, in virtually all cases, is to list them as a dependency in the project.clj file for your project. In other words, use leiningen. You can also download them from clojars. Or you can clone their github repos, and compile them individually, and copy them into the lib directory of your project. But seriously, just use leiningen.

Rob Lachlan
@Rob : I found that clojure.contrib.repl-utils libs are not ready even for the update. And I added the question to the original post. Could you check that?
prosseek
+1  A: 
  1. A lot of functions in clojure-contrib moved into clojure core in Clojure 1.2. The diffrence between now and 1.1 is about the same as the growth of clojure.core.

  2. get the leiningen update

  3. don't know I just use leiningen

  4. Just add it to your project.clj in leinigen

nickik