> I'm sure this was considered

 

Indeed, and when clojure.spec was first introduced, instrument did check :ret 
and :fn specs. That feature was deliberately removed and the reason for it is 
(paraphrased):

 

* clojure.spec/instrument helps check that your functions are _called_ correctly

* clojure.spec.test/check helps check that your functions are _implemented_ 
correctly

 

Those are two different concerns and they should not be complected into one 
function. The argument checks performed by instrument are straightforward: are 
the arguments valid? The function invariant is checked by performing generative 
testing.

 

See this thread for some of the discussion around this (and Rich has also 
discussed in on Slack quite a bit):

 

https://groups.google.com/d/topic/clojure/RLQBFJ0vGG4/discussion

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

On 8/6/16, 10:02 AM, "Tom Connors" <clojure@googlegroups.com on behalf of 
t.v.conn...@gmail.com> wrote:

 

spec.test/instrument doesn't check the return value of spec'd functions and 
according to the spec guide this is because we should be checking function 
implementations at testing time, not development time. It seems to me that 
adding :ret and :fn checks to instrumented functions would be worthwhile even 
though tests are a better place to do those checks - since instrumentation is 
meant to be turned off in production the performance hit doesn't matter, and 
since we're already verifying that the arguments conform to spec, why not check 
the return value as well? A benefit would be that if we haven't yet written (or 
won't write) generators and tests, we still get a confidence increase about our 
instrumented functions' return values. 

I'm sure this was considered, so I'm just wondering if "do that in your tests" 
is the entire reason for this design choice.

 

-- 
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.

Reply via email to