I have recently converted a library zprint to work with spec in both 1.8 and 1.9-alpha15, using clojure-future-spec to make 1.8 compatible (from a spec viewpoint) with 1.9. It has worked great, and I have been delighted with how easy it was to build a library that had the same code in both 1.9 and 1.8 and used spec. In 1.9-alpha15 it uses the "built-in" spec, and in 1.8 people have to add clojure-future-spec as a dependency, which is a small thing. Thank you so much for creating this library so that we can use spec in both versions!
Of course, now things have changed and the namespaces for spec have all changed in 1.9-alpha16. This breaks my "one library works in 1.9 or 1.8" approach, since the "works in 1.8" part requires that the namespaces in clojure-future-spec be the same as the namespaces in 1.9-alpha16.
That said, now that spec is a library, it would seem that I could just add it as a dependency for my 1.8 code and use that. But in the announcement, Alex said that spec wasn't going to support 1.8 since it uses new functions that only exist in 1.9 (and in clojure-future-spec). I tried various approaches to adding clojure.future
as a dependency and requiring it, but I can't even get that to work by adding it to the (ns ...)
because the spec.alpha code looks for the new functions explicitly in clojure.core (via an alias). I don't see a way around that, but if there is one, I'd love to hear about it.
Even if that worked (which it doesn't for me), I don't know of a way to get the clojure-future-spec clojure.future
namespace loaded along with the new spec libraries only in 1.8 and not have it throw an error in 1.9. There might be a way to put the require in a (try ... catch)
, but I can't even try that because it doesn't work at all the way things are now even with the require in the (ns ...)
declaration.
I'm hoping that at some point you will back-port the latest 1.9-alpha16 spec stuff for 1.8, as you have before with the alpha15 code.
It has been really great to have one spec that we can use in both 1.9 and 1.8. Thank you for making that possible. I really appreciate it, and I know I'm not the only one!