News for hackers. Stuff that matters.
Re:Six Years of Professional Clojure by modernerd on Monday August 02, 2021 @11:12AM (#28037584)
Does the spec logic typically live inside the modify-inventory function, or elsewhere? If elsewhere, what triggers it before the function is called?
Re:Six Years of Professional Clojure by teataster on Monday August 02, 2021 @12:08PM (#28038513)
There is very little spec logic. It looks a lot like type declarations in typed languages.

It's usually outside the scope of functions, since you are likely going to want to reuse those declarations. For example, you can use spec to generate test cases for something like quick-check.

You can add pre and post conditions to clojure function's metadata that test wether the spec complies with the function's input/output.