This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-01
Channels
- # admin-announcements (20)
- # aws (24)
- # beginners (323)
- # boot (60)
- # business (1)
- # cider (23)
- # clara (7)
- # cljs-dev (38)
- # cljsrn (12)
- # clojure (302)
- # clojure-canada (5)
- # clojure-dev (26)
- # clojure-miami (1)
- # clojure-nl (13)
- # clojure-russia (64)
- # clojurecup (1)
- # clojurescript (202)
- # clojurex (4)
- # code-reviews (5)
- # core-async (23)
- # cursive (39)
- # datavis (26)
- # datomic (34)
- # devcards (5)
- # editors (19)
- # emacs (4)
- # events (6)
- # funcool (55)
- # hoplon (5)
- # ldnclj (3)
- # lein-figwheel (1)
- # luminus (15)
- # om (159)
- # omnext (7)
- # onyx (107)
- # slack-help (2)
- # testing (3)
I need some help, with this problem: I have a map which has some channels in it. I want to fill them in one function, and read it in another function. How could I handle this?
(def container {:channel1 (chan)
:channel2 (chan)})
(defn func1 [container]
(go
(>! (:channel2 container) (<! (:channel1 container))
))
(defn func2 [container]
(go
(println (<! (:channel2 container)))
(>!! (:channel1 container) „Test")
Is this possible?
is there a way to get more detail for this error in cljs/node.js? https://gist.github.com/sander/7699c3912286f3c3fe53
danielgrosse: It’s hard to tell what you’re trying to do, but fwiw, you’re never calling func1
and func2
in that code snippet.
@erik_price: I’m just getting my head around async. And the documentation I found in the web, weren’t so much helpful. I just found a way, with put! and take! to achive it.
oh ok
Is there some way to find out if you are inside a go
block? Like (go (= true (am-i-in-a-go-block?)))
?
(= false (am-i-in-a-go-block?))
@codemartin: why would the code need to know?
@swizzard: mostly for my repl - I keep doing (while true (...))
and then everything hangs, if I don't do it in a go
-block.
exactly
oh so you wanna be able to like short-circuit or whatever if you're in the main thread
@swizzard Exactly
so i don't know for sure, but i will go out on a limb and say that if there is a way to identify which thread some block of code is running in, it's likely to be some extremely ugly and unclojuric piece of interop magic dependent on obscure/intentionally obscured java internals
and your better bet would be to mock out your data/termination condition when playing around in the repl
@swizzard: maybe step one is to start using termination conditions at all!
Another solution is not doing (while true)
, but
;;; pseudocode
(defn go-forever [& form] (go (while true form)))
insteadand i've personally lost too many hours to assumptions about program state to let someone else make the same mistakes
Yeah it is only for side-effecty code (just like go
).