Fork me on GitHub
Ivan Koz05:07:38

Is it possible to de-structure namespaced keywords like {:profile/id 123 :profile/name "abc"}


(let [{:profile/keys [id name]} data] ...)

☝️ 3

Checkout also the destructuring guide for some additional information: The Namespaced keywords section in particular

Ivan Koz05:07:29

whoa, i've looked that document before and missed it, ty

Bart Kleijngeld12:07:06

I'm going to write my first unit tests for a project, and I was looking for some inspiration. The core clojure.test library seems fine, but perhaps I'd be missing out (I also like pytest way better than Python's core unittest library 😉). Any tips/experiences?

Bart Kleijngeld12:07:04

I've also heard positive stories about


What sort of things are you missing in clojure.test? Often clojure is much more extensible than you think if you feel something is missing 😉


If you are a beginner give clojure.test a try. It is good enough to begin with and only when (or if 😉) you hit some problems — look at another helpers


Midje has quite the mixed feelings here in the community and I'd also recommend start off with clojure.test and see whats missing

Bart Kleijngeld13:07:36

I'm unfamiliar with both (all) options, so I'm not missing something, but was curious what place was best to start. Sounds like giving clojure.test a try is a good way then. Thanks 🙂

👍 2

You may also use as a clojure.test extension in case you miss something.

gratitude 1

Can't load library: /usr/lib/jvm/java-17-openjdk/lib/
do you know why cider middleware tries to load this and it is not there? Works when I don't manually set the jdk path to opendjk 17


Can't load library: /usr/lib/jvm/java-17-openjdk/lib/
ERROR: Unhandled REPL handler exception processing message {:op stacktrace, :nrepl.middleware.print/stream? 1, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/buffer-size 4096, :nrepl.middleware.print/options {:right-margin 70}, :session 8e0cd955-f748-4dc5-a446-fefdff3d06da, :id 445}
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class java.awt.image.ColorModel
	at java.base/
	at java.base/java.util.concurrent.FutureTask.get(
	at clojure.core$deref_future.invokeStatic(core.clj:2317)
	at clojure.core$future_call$reify__8544.deref(core.clj:7041)
	at clojure.core$deref.invokeStatic(core.clj:2337)
	at clojure.core$pmap$step__8557$fn__8561.invoke(core.clj:7092)
	at clojure.lang.LazySeq.sval(
	at clojure.lang.LazySeq.seq(
	at clojure.lang.RT.seq(
	at clojure.core$seq__5467.invokeStatic(core.clj:139)
	at clojure.core$map$fn__5939.invoke(core.clj:2774)
	at clojure.lang.LazySeq.sval(
Caused by: java.lang.NoClassDefFoundError: Could not initialize class java.awt.image.ColorModel
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(
	at clojure.lang.RT.classForName(
	at clojure.lang.RT.classForName(
	at clojure.lang.Compiler.maybeResolveIn(
	at clojure.core$ns_resolve.invokeStatic(core.clj:4371)ERROR: Unhandled REPL handler exception processing message {:op eldoc, :ns user, :sym java.awt.image.ColorModel, :session 8e0cd955-f748-4dc5-a446-fefdff3d06da, :id 451}
java.lang.NoClassDefFoundError: Could not initialize class java.awt.image.ColorModel


I mention cider because it seems to throw inside the nrpel handlerr


nvm when I run without nrpel I get the same error. First clj start like usual, then I eval (require '[nextjournal.clerk :as clerk])

Execution error (UnsatisfiedLinkError) at java.lang.ClassLoader/loadLibrary (
Can't load library: /usr/lib/jvm/java-17-openjdk/lib/
also this file does not exist at that location. Maybe I just need to install libaws_xawt


ah I'm almost certain it is because I have jre17-openjdk-headless but I should use not headless to use clerk


can confirm installing jre17-openjdk fixed my issue

🍺 1

What is the basic way to to run functions sequentially, but have the values available for subsequent functions? Like a do-> thread..? I am trying to tie together api I/O functions, where there is some latency for results. (I guess this falls into async territory?) kind of like this:

(let [new-item-name "name"]
  (create-item! new-item-name)
  (let [new-item (get-item item-name)] ; with system-supplied id
    (update-item! (:id new-item))))

Ivan Koz19:07:33

could you rephrase your question? Not sure what you are asking, did you mean

(let [new-item-name "name"
      new-item (create-item! new-item-name)]
     (update-item! (:id new-item)))


Yes. That is simpler. But do the let bindings resolve before the body runs? create-item! and update-item! have network latency.


I guess in this case the update-item! latency doesn’t impact the function.


I’m sorry, no, create-item! and get-item are separate. Because when an item is created, is is supplied with a unique :id from the system. So I need to “create”, and then “get” a particular entity, before I can “update” it (via it’s :id )


(let [new-item-name "name"
      ;; assuming create-item! runs blocking and has the side effect of creating an item
      _ (create-item! new-item-name)
      new-item (get-item item-name)]
  (update-item! (:id new-item)))
Like this everything runs sequentially. It doesn't matter if any of those calls are doing long running io. (same as your code but I put everything into a single let)


Ok, Thanks for the clarification