schema.core/defn puts a lot of code in my namespace

29 views
Skip to first unread message

michae...@lendup.com

unread,
Jul 9, 2017, 1:55:59 AM7/9/17
to Plumbing and Graph: the Clojure utility belt
Replacing clojure.core/defn with schema.core/defn puts a lot of validation and error reporting code in my namespace. If I use cloverage, that code is marked as uncovered, because I never violated the contracts for my functions. I'm wondering if it'd be possible to hove some of those code moved into functions in schema which the macro-expansions could call. It's been my experience that this sort of refactor tends to make macros a bit easier to reason about anyway.

michae...@lendup.com

unread,
Jul 9, 2017, 1:56:28 AM7/9/17
to Plumbing and Graph: the Clojure utility belt
*have some of that code

Jason Wolfe

unread,
Jul 9, 2017, 2:37:21 PM7/9/17
to michae...@lendup.com, Plumbing and Graph: the Clojure utility belt
Thanks for the suggestion.  There are a few conflicting factors at play here.  One is code bloat/cleanliness as you mention.  The other is clarity of error messages (and performance) which we have treated as more important.  

In particular, when validation on a function fails, we want the top of the stack trace to be the function in question and not a helper method deep inside schema.  And, from a performance point of view, want to avoid any var derefs in the common case that validation is turned off.  For both of those properties to hold, at least those two bits have to be inlined. 

Thoughts?  We're open to contributions of cleanups but also probably wouldn't want to sacrifice clarity of error messages or performance without a really good reason.  

-Jason


--
You received this message because you are subscribed to the Google Groups "Plumbing and Graph: the Clojure utility belt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prismatic-plumbing+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages