mount

oskarkv 2026-04-14T14:32:08.604779Z

Hi! I'm new to mount. I tried this:

(defstate arena
  :start (Arena/ofConfined)
  :stop (.close arena))

(defn create-instance
  []
  (.createInstance wgpu (WGPUInstanceDescriptor/allocate arena)))

(defstate instance
  :start (create-instance)
  :stop (release-instance instance))
And I get this error:
could not start [#'game.webgpu/instance] due to
class game.webgpu$arena cannot be cast to class java.lang.foreign.Arena
So apparently when trying to run (create-instance), arena is not an arena. But I thought the whole point of mount was that I would be able to do something like this. What is wrong? I also tried with taking the arena as an argument to create-instance, but that did not change anything.

tolitius 2026-04-14T14:37:25.342119Z

does calling:

(.createInstance wgpu (WGPUInstanceDescriptor/allocate (Arena/ofConfined))))
work as intended? not sure what “`WGPUInstanceDescriptor`” and “`Arena`” are, but your assumption is correct, mount uses Clojure compiler to discover the dependencies, and the “`arena`” state would need to be compiled first before it can be used in “`create-instance`”

oskarkv 2026-04-14T14:44:01.847299Z

WGPUInstanceDescriptor comes from WebGPU (graphics library) native bindings, and arena is a native memory segment. But anyway, I restarted my REPL to try everything from a fresh state and had some other problems, excuse me for a bit...

oskarkv 2026-04-14T14:51:58.320149Z

Hm, after restarting my REPL and fixing some other things (seemingly unrelated things) it now works.

👍 1
oskarkv 2026-04-14T14:54:00.885079Z

I was refactoring my code to use mount and I don't know what weird state I ended up in.