I think you're on the right track, personally. We've had a macro similar to 
that which we've been using for a handful of months. Just this week, I rewrote 
it using the defn specs from clojure.specs.alpha to support all of the forms 
which defn supports, including multiple arities with different specs for each. 
The goal is to add the macro to orchestra, as a tool to help encourage spec'ing 
all functions.

A lot of people are separating their specs from their functions and can make 
some arguments for why it should be done. For my team, in practice, it's been 
much easier to keep them as close as possible to their functions. This helps 
minimize time spent maintaining them, ensures that they don't fall out of date, 
and encourages their use, as you've demonstrated, by inlining them into the 
typical defn-like environment.

On Tue, Sep 19, 2017 at 02:29:33PM -0700, Didier wrote:
> I've been thinking since using Clojure.spec fdef that I'd like something 
> like this:
> 
> (defns foo
>   [x string? y int?] string?
>    forms)
> 
> Where an s/fdef spec automatically build of this form:
> 
> (s/fdef foo
>   :args (s/cat :x string? :y int?)
>   :ret string?))
> 
> 
> And obviously the foo var and function would also be created.
> 
> I feel like the core team didn't choose this route though, and so I'm 
> curious why, and if its actually a bad idea?
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> 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 clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to