conditional support for spec in libraries

93 views
Skip to first unread message

Charles Loomis

unread,
Oct 23, 2016, 11:49:33 AM10/23/16
to Clojure
The only discussion I’ve seen about providing conditional support for spec in libraries is in the old thread started by Sean Corfield for the JDBC library:

https://groups.google.com/d/msg/clojure-dev/4VAlKZxiN94/tNQo_4yABAAJ

Is the technique described there, the recommended best practice? Or should we expect to see a :spec feature expression added to Clojure 1.9+? Do people have other ways of providing conditional spec support in libraries targeted at multiple clojure versions?

Any feedback appreciated.



Lei

unread,
Oct 23, 2016, 1:56:52 PM10/23/16
to Clojure
graphql-clj library tries to support both Clojure 1.9 and 1.8. 

The way it does: 

Library use Clojure 1.9 as dependency. 

For project uses Clojure 1.8 and depends on graphql-clj, it has a few options: 

1. Don't use the namespace with clojure.spec

or

2. Add https://github.com/tonsky/clojure-future-spec as dependency, clojure.spec backport will be available. 

Caveat: For some new functions introduced in clojure.core 1.9, simply copied those functions to library.

Alex Miller

unread,
Oct 23, 2016, 3:01:20 PM10/23/16
to Clojure
We do not plan to add a :spec feature expression (also, feature expressions are not actually a thing - the final version of reader conditionals only supports platform tags).

Max Penet

unread,
Oct 23, 2016, 3:48:34 PM10/23/16
to Clojure
Another way is to provide the specs as a separate (or "sub") project. You then dont have to care about clojure versions, potential aot issues etc.

I do this in https://github.com/mpenet/alia

The same approach is taken with all features that could be considerrd opinionated and relying on external dependencies (core.async, manifold etc).

Reply all
Reply to author
Forward
0 new messages