This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-13
Channels
- # ai (5)
- # announcements (4)
- # babashka (34)
- # beginners (78)
- # biff (6)
- # calva (41)
- # cider (47)
- # clerk (1)
- # clj-commons (3)
- # clj-http (1)
- # clojure (72)
- # clojure-europe (51)
- # clojure-nl (1)
- # clojure-norway (87)
- # clojure-romania (1)
- # clojure-uk (5)
- # clojuredesign-podcast (2)
- # community-development (1)
- # conjure (2)
- # cursive (11)
- # datomic (6)
- # docker (4)
- # emacs (13)
- # exercism (20)
- # hyperfiddle (56)
- # matrix (6)
- # membrane (4)
- # nbb (11)
- # off-topic (88)
- # pathom (7)
- # pedestal (1)
- # polylith (20)
- # portal (16)
- # practicalli (1)
- # re-frame (13)
- # reagent (4)
- # reitit (2)
- # remote-jobs (7)
- # shadow-cljs (49)
- # sql (4)
Does watching this get the Matrix message across, or just leave you scratching your head? Please do not spare my feelings, I will get better. Thx! https://youtu.be/Nmu_IAw2YJs
I'm not a fresh set of eyes, per se, but it was clear to me! ✅
On a separate note, (let me know if you would like separate thread), the with-mx-isolation is unique to ClojureDart, yes? I vaguely remember you saying it had to do with a disparity between regular Clojure and ClojureDart in how they handle dynamic variables, but I don't remember the specifics.
Perhaps that disparity might be considered a bug in ClojureDart that could be fixed?
I'm curious, because aside from lthe pet-peeve of calling with-mx-isolation looking a little noisy, a common point-of-friction I ran into was hunting through code to see if I'd already called it or not. And "calling it again just to be sure" sometimes caused other problems.
I.E. fn-A calls fn-B calls fn-C. While writing fn-C (often in a different namespace) I'll forget weather fn-A or fn-B have already run with-mx-isolation
or not.
Thx for looking!
"with-mx-isolation is unique to ClojureDart...Perhaps that disparity might be considered a bug in ClojureDart that could be fixed?"
I never sorted it out, I just plowed ahead. 🙂 I did have an exchange with Team CLJD and explored a little. I decided the threading model might be different. Hmmm, let me compare with CLJS and CLJ sometime this weekend. But yeah, in CL or other CLJS I have never needed this,
"I.E. fn-A calls fn-B calls fn-C. While writing fn-C (often in a different namespace) I'll forget weather fn-A or fn-B have already run with-mx-isolation
or not."
Are you saying C might be called directly by some event handler or async callback, or it might be called by B? I guess one answer is to have with-mx
(proposed new name 🙂 ) lexically appear only in a handler etc, sth at the edge of MX.
"it was clear to me!"
Watching it myself, I think better lighting/ergonomics would make my typing less tortured. Talking and typing at the same time does not help. 🙂
Thx again for the input! 🙏
So I did some digging on dynamic vars. Wow.
This: https://clojureverse.org/t/binding-in-the-context-of-future-vs-thread/3718
...links to this: https://stuartsierra.com/2013/03/29/perils-of-dynamic-scope
I found https://clojuredocs.org/clojure.core/bound-fn, which in CLJ copies dynos to a diff thread. (The effective CLJD behavior.)
In the first link someone reports futures see dynos because CLJ silently copies them to the thread!
I did confirm that in Web/MX aka CLJS dynos are not visible to callbacks.
So I think ClojureDart's behavior is arguable, @U013TCGL92T. And it prolly derives from the single-thread thing in Dart, so would take some work to change.
The good news is, we only need with-mx-isolation
when doing mset!/mswap!
in callbacks. And we can shorten the name. 🙂
The punch line is, I made an unrelated change adding a widget and BAM! the volume slider et al blew up, because I had never wrapped their handlers in with-mx-iso
! I went back a month of commits and sure enough the critical vars spawning the callback were false (so no problem doing a state change), whereas after the innocuous change they were true.
I think I'll shorten it to wmx-iso
. 🙂
For the curious:
(defmacro wmx-iso [& body]
`(binding [tilton.mx.cell.base/*within-integrity* nil
tilton.mx.cell.base/*depender* nil
tilton.mx.cell.base/*defer-changes* false
tilton.mx.cell.base/*call-stack* nil]
~@body))