2 ms·
Function specs are not about compile time verification: they are about checking that the object you got is the thing you thought you had. Compile time verifica
by lvh 8y ago
Function specs are not about compile time verification: they are about checking that the object you got is the thing you thought you had.
Compile time verification is nice if you know all your inputs at compile time. At some point, data from elsewhere comes in. Specs are an answer that preserve the composability goals of Clojure (who cares if I have a bit more information than I strictly need?) and allow you to validate them at runtime with useful error messages.
spec has incidentally made Clojure's compile term error messages better! But that's just because one program's compile time is the compiler's runtime, and the compiler is running spec verifications on your code (which is after all, just data!) during its runtime :-)