My two cents:
Adding spec inside the original namespace is more readable, provide
documentation just in place, and the user do not need to require a separate
namespace to get spec of your API, I will prefer it.
For users stay in < clojure 1.9.0, I use this macro in my code:
(defmacro opt-require
"Optional requires rqr-clause and if it succeed do the body"
{:style/indent 1}
[rqr-clause & body]
(when
(try
(require rqr-clause)
true
(catch Exception _
false))
`(do ~@body)))
(opt-require [clojure.spec.alpha :as s]
(s/def ::my-spec int?))
On Saturday, September 15, 2018 at 1:00:30 AM UTC+8, Howard M. Lewis Ship
wrote:
>
> I'm thinking of releasing a tiny library (really, just one macro), and I
> want to document/validate using spec.
>
> What's the accepted approach for bundling the macro with its spec:
>
> - Just add the spec right in the namespace with the macro
> - Have a second optional namespace that provides the spec for the macro
> - Something I haven't thought of
>
> --
> Howard M. Lewis Ship
>
> Senior Mobile Developer at Walmart Labs
>
> Creator of Apache Tapestry
>
> (971) 678-5210
> http://howardlewisship.com
> @hlship
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.