Fork me on GitHub
#clojure-spec
<
2018-05-03
>
pyr07:05:46

Let me post my twitter question here as well 🙂 > Clojure library writers, what's your position on spec asserts? Leave it to library consumers to set, leaving it to calling code to> choose whether to assert or not, or enforcing it from the library to ensure malformed payloads always throw?

joost-diepenmaat11:05:48

do you mean using spec.alpha/assert ?

joost-diepenmaat11:05:15

probably wouldn’t use that in a library, I’d rely on instrument during dev/test. if you’ve got data coming in that must be validated (say user input or stuff coming in over a network) then you do an unconditional (when-not (s/valid ..) (throw …))

joost-diepenmaat11:05:41

note that assert can be turned off by changing *compile-asserts*

joost-diepenmaat11:05:58

and you wouldn’t want that for stuf that must be checked.