Is some code in clojure.contrib broken with Clojure 1.3?

Since Clojure 1.3 "Earmuffed Vars is no longer automatically dynamically viewed", some code in clojure.contrib is dependent on this function and they no longer work. For example, db in clojure.contrib.sql.

Warning: *db* not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic *db* or change the name. Exception in thread "main" java.lang.RuntimeException: java.lang.ExceptionInInitializerError 

The Contrib library is stored in version 1.2. How to get around this? Or is there some kind of alpha or preview version of Contrib lib that can work with Clojure 1.3?

+4
source share
2 answers

When Clojure moved to 1.3, it was decided to abandon the monolithic contribution, that is, one Contrib library containing a bunch of independent projects. The reason for this - afaict - was that some libraries were abandoned, and it was difficult to get people to upgrade them to 1.3.

In addition, several libraries have also changed their name. An overview can be found here: http://dev.clojure.org/display/doc/Clojure+Contrib In particular, the contrib.sql library was renamed to java.jdbc and now lives here https://github.com/clojure/java .jdbc

+6
source

Often the vars were headphones that did not expect a rebound, so it is possible that everything will work without it.

However, you can override the old var as follows, allowing it to dynamically re-bind:

  (in-ns' other.ns)
 (def ^: dynamic * foo * * foo *)
0
source

Source: https://habr.com/ru/post/1379273/


All Articles