Thursday, January 3, 2013

Clojure conditional feature reader

I’ve been experimenting with tagged literals and data-readers to create what I’m calling a “conditional feature reader”. The basic element is the condf tag, which works sort of like cond but the tests are “feature requirements”. A feature requirement can be something like clj1.5 (meaning Clojure 1.5) or java1.6+ (meaning JDK 1.6 or greater). For example:

(println #feature/condf [(and jdk1.6+ clj1.5.*) "Ready for reducers" else "No reducers for you."])

I’ve only implemented it for regular Clojure 1.4 and 1.5 (on the JVM), but I’m hoping it might prove useful for other variants such as ClojureScript.

For more details, see:

https://github.com/miner/wilkins

Posted via email from fnclojure

No comments: