Is there any guidance on how to do the fdef for a function with more than
one arity? As an example, this one which takes one or two arguments:
(defn report
"Report an error code, optionally with a message"
([errno] ...)
([errno msg] ...))
Could be:
(s/fdef report
:args (s/alt :brief (s/cat :errno integer?)
:full (s/cat :errno integer? :msg string?)))
or:
(s/fdef report
:args (s/cat :errno integer? :msg (s/? string?)))
Some options make more sense than others, depending on the function. For
example clojure.core/map is defined with five separate arities but I don't
think it would be right to spec it as an alt with five alternatives, since
they are all covered by "function followed by zero or more colls"
So, has a convention been established on how best to do it?
--
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.