4 ms·
I thought they were going to hold this until Clojure/conj 2024. No particular reason to believe so (besides Clojure 1.10 being released around the same time as
by koito17 2y ago
I thought they were going to hold this until Clojure/conj 2024. No particular reason to believe so (besides Clojure 1.10 being released around the same time as Clojure/conj 2021 and the Datomic-becoming-free announcement being done at the very start of Clojure/conj 2023).
Still waiting on spec2, though... for now I am working around rigidity of specs by using Malli but it really isn't a first-class citizen in Clojure (mostly due to inability to check macros, and this is by design of the Clojure compiler). But you can emulate the ideas of schema/select by manipulating malli schemas as data.
The changes for functional interfaces also means we no longer have to maintain utility macros like
(defmacro ->Consumer [f]
`(reify java.util.function.Consumer
(accept [this arg#]
(~f arg#))))
and instead just pass functions directly.
- eduction 2y agoWhat do you mean by “inability to check macros”? You can s/fdef macros with spec and it checks the calls at compile time. In fact Clojure core uses spec to check macro calls as you can see in the stack trace sometimes when you call one wrong. Do you mean something else?
- koito17 2y agoHere's what I mean by Malli's inability to check macros. https://github.com/clojure/clojure/blob/ad54fec/src/jvm/clojure/lang/Compiler.java#L7520 https://github.com/clojure/clojure/blob/ad54fec/src/jvm/cloj... The Clojure compiler directly calls into clojure.spec and does not expose any sort of hook for validating macros. No library can validate macros except clojure.spec. In this sense, Malli feels like a second-class citizen in Clojure compared to the built-in clojure.spec.
- eduction 2y agoAh thanks for explaining! I did not know they special cased spec. I hope that changes.
- doubleg 2y agoI really wanted schema/select after watching “maybe not”, so wrote a library for malli: https://github.com/eval/malli-select https://github.com/eval/malli-select
- stingraycharles 2y agoMalli really is what spec should have been.