This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-26
Channels
- # beginners (20)
- # cider (59)
- # cljsrn (6)
- # clojars (7)
- # clojure (91)
- # clojure-boston (1)
- # clojure-dusseldorf (3)
- # clojure-finland (1)
- # clojure-italy (8)
- # clojure-losangeles (1)
- # clojure-nl (16)
- # clojure-spec (25)
- # clojure-uk (113)
- # clojurescript (126)
- # core-async (27)
- # cursive (5)
- # data-science (3)
- # datomic (22)
- # emacs (24)
- # fulcro (30)
- # garden (7)
- # graphql (7)
- # leiningen (3)
- # nginx (1)
- # off-topic (63)
- # onyx (13)
- # portkey (1)
- # re-frame (1)
- # reagent (28)
- # shadow-cljs (92)
- # tools-deps (1)
- # uncomplicate (1)
- # vim (24)
- # yada (8)
@danboykis it's a PoC code the design isn't important to me, my main concern is that a piece of code which uses a value extracted from a channel and outside of a go block, does it actually runs on the main thread or not
(go (<! c))
would extract a value from the channel, but it will be in a new channel returned by the go
block
in your example some-fn
would be called on the main thread with an argument being a channel v
if you use <!!
some-fn
will also be called on the main thread but the argument v
will be the value taken from channel c
@danboykis yeah you're right, I forgot that go
returns a channel itself
I have a try/catch block inside a go
block, and in the catch block, I put the exception onto an error channel, and when I read it from that channel, I just log it to the REPL. This works and catches exceptions, but I can't see a stacktrace. Any suggestions?
why would you see a stacktrace? you mean the logging step isn't happening?
it logs but it just says java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
I'm sure the error is easy to track down if a I see a trace.
@ajs - that's just the message - why not print the stack trace? if you use pr-str clojure will make the whole stack trace part of the printed representation of the exception
or prn instead of println
right, *e is for the repl
then use prn
or, pr - since print is println without the newline, and pr is prn without the newline
println uses toString, which is defined by java.lang.Exception in java and does not include the stack trace, prn uses print-method and is defined in clojure code and does include the stack trace
so the short version is - clojure does the convenient thing, java doesn't, use prn to get the clojure version
in general, you can use prn to get clojure's idea of how a thing should print, and println to get java's version
(that's a vast oversimpliciation, there's more to it)
the prn version is often "readable" so you could read the string and make an equivalent piece of data (doesn't apply to exceptions)