4 ms·
I will use your language, but no offense, if I see this in something I have to maintain I'm rewriting it. (defn transformed-belt [xf] (let [ch (chan 1 xf
by alexvitkov 3y ago
I will use your language, but no offense, if I see this in something I have to maintain I'm rewriting it.
(defn transformed-belt [xf]
(let [ch (chan 1 xf)]
(thread
(loop []
(when-some [value (<!! ch)]
(println "Value:" (pr-str value)))
(recur)))
ch))
No clue what it means, but I'm convinced it can be written in 3 lines with a for loop in a way that 100% of people looking it will understand it, and not 5%. Probably even in Clojure!
- deleted 3y ago[deleted]
- mksybr 3y agoI'm not expert Clojurist, but my first guess of this is that it prints and pushes every non-nil value into a go channel xf, one-by-one, recursively, in a new thread, then return the channel, presumably so more work can be done and passed to it. The number of exclamations in <!! means something, but I forget what, I think something about non/blocking.
- adityaathalye 3y agoWhat design choice / contract do you think you will break if you were to unilaterally rewrite such a thing?