This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-03
Channels
- # admin-announcements (6)
- # beginners (73)
- # boot (84)
- # cider (9)
- # cljs-edn (5)
- # cljs-site (8)
- # cljsrn (2)
- # clojure (158)
- # clojure-austin (1)
- # clojure-canada (1)
- # clojure-dusseldorf (2)
- # clojure-ireland (1)
- # clojure-russia (45)
- # clojure-sg (2)
- # clojure-uk (28)
- # clojurebridge (2)
- # clojurescript (142)
- # core-async (43)
- # cursive (23)
- # datascript (5)
- # datomic (9)
- # dirac (4)
- # emacs (23)
- # funcool (1)
- # garden (1)
- # hoplon (280)
- # jobs (1)
- # ldnclj (6)
- # leiningen (37)
- # luminus (6)
- # om (30)
- # om-next (1)
- # onyx (6)
- # perun (24)
- # re-frame (10)
- # reagent (20)
- # remote-jobs (1)
- # rethinkdb (2)
- # ring-swagger (4)
- # rum (3)
- # spacemacs (6)
- # untangled (36)
- # yada (5)
i have a question about (thread (loop
in core.async
i posted a SO post about it here http://stackoverflow.com/questions/37010570/should-one-put-while-true-inside-of-a-clojure-core-async-thread/37011689#37011689
so it looks like i shouldn’t do (while true
in a (thread
but is it safe to do a (thread (loop [data (<! chan)]
either?
given that a loop in (go
is (go-loop
i imagined that was a specialized version of (go
hmm. well that is not the case:
(defmacro go-loop
"Like (go (loop ...))"
[bindings & body]
`(go (loop ~bindings ~@body)))
@hiredman: well thats good to know
i can say that when i close the chan, even the thread chan, and i’m in a repl
i still see prn
lines outputting
so it doesnt look to me like loop
releases
(`prn` lines within the while
loop)
but this doesnt make sense to me. wouldn’t this mean that even go-loop
s don’t stop looping?
i mean, unless there is some special means via which bindings in go-loop
s are monitored, i would guess?
i want to be able to stop yes
man, now i’m wondering how go-loop ever stops looping
so basically only do it if you plan on never stopping the loop
base condition yes
but with a chan, it could resume, if its go-loop [data (<! my-chan)]
like how do you base condition and then not base condition
so i use the fact that chans return nil
when they’re done to avoid the recur?
everything makes sense!
thank you @hiredman
i always wondered why you can’t pub nil
to a chan
makes sense now