Journal 2019.16 - closed spec checking

Closed spec checking

As I mentioned last week, I’ve been working on adding a new form of closed spec checking and that’s in master for spec 2 now, or at least the first cut of it. The idea is that you can mark one or more (or all) specs as “closed” and they will then act in that mode for valid?, conform, and explain until you open them again. The specs themselves are unaltered - there is no marker in the symbolic spec form indicating “closed”-ness, rather this is a checking mode that you can turn on, kind of like instrument.

(require '[clojure.spec-alpha2 :as s])
(s/def ::f string?)
(s/def ::l string?)
(s/def ::s (s/schema [::f ::l]))
(s/valid? ::s {::x 10})  ;; "extra" keys are ok
;;=> true

;; now "close" the ::s spec (no-arg arity closes all specs)
(s/close-specs ::s)
(s/valid? ::s {::x 10})
;;=> false

(s/explain ::s {::x 10})
;; #:user{:x 10} - failed: (subset? #{:user/f :user/l} (set (keys %))) spec: :user/s

;; now open again
(s/open-specs ::s)

(s/valid? ::s {::x 10})
;;=> true

Still a lot of open questions about the API, behavior, etc, but this should give you an idea.

Clojure 1.10.1

We had some good feedback at the beginning of the week on Clojure 1.10.1-beta2, particularly about the error reporting aspects which go to a file. I continue to think that the default of writing to a temp file is best, but grew unsatisfied with the configurability of what was there, which was only a new clojure.main option. Instead of having a flag, decided it should be an enumeration of options - file (for temp file), stderr, and none. Also, having it just as a flag on clojure.main meant that every external launcher didn’t know how to do that, whereas making it a Java system property is already a configurable path that these tools (like Leiningen) can already handle. So, I made it check Java system property, then optionally override from clojure.main flag, and default to file mode. This is all captured in CLJ-2504 which I expect will go through screening next week.

I’m also growing a little concerned at the number of people patching around CLJ-1472 for Graal so will probably discuss that with Rich and consider whether to do anything for 1.10.1. The proposalss are tricky and may have unexpected perf impacts so its a difficult one to assess.

In any case, we would like to bring this release to an RC soon and get it released.

Rich has a couple api additions he put together this week related to metadata retention and those will get slotted in once we’re looking at 1.11 again.

Other stuff I enjoyed this week…

I haven’t had many music recommendations lately as I went through a bit of a dry spell. But I listened to a lot of music this week! My son is a drummer and has been doing an Aretha Franklin / Stevie Wonder show recently so it’s been a lot of fun watching him listen to a lot of stuff I’ve loved for a long time but that’s new to him. So many great tracks on Songs in the Key of Life, but he’s particularly digging on Sir Duke and the oddball Contusion this week.

In newer music, I really dug Lay Back by CLAVVS (pronounced “claws”), that’s from a 3-song EP and I like all 3 tunes on that.

I also want to give a shout-out to Stuart Sierra’s new podcast No Manifestos - the first 3 episdodes were all great! I really enjoyed listening to them.

Also, outside the Clojure world I run this little conference called Strange Loop - the CFP is open now, please submit!

Written on April 19, 2019