This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-01
Channels
- # 100-days-of-code (2)
- # beginners (83)
- # calva (3)
- # cider (98)
- # clara (3)
- # clj-kondo (2)
- # clojure (84)
- # clojure-dev (59)
- # clojure-europe (11)
- # clojure-italy (22)
- # clojure-madison (4)
- # clojure-nl (3)
- # clojure-spec (24)
- # clojure-uk (80)
- # clojurescript (33)
- # clr (3)
- # datomic (59)
- # events (2)
- # fulcro (20)
- # interop (35)
- # jobs (6)
- # jobs-rus (1)
- # joker (3)
- # kaocha (2)
- # luminus (3)
- # off-topic (16)
- # other-languages (2)
- # pathom (17)
- # planck (2)
- # reagent (1)
- # shadow-cljs (1)
- # test-check (1)
- # tools-deps (49)
- # vim (16)
sounds like the answer is if working with transducers or if you want the property of nil
returning ()
I donโt think Iโve ever used it in 10 yrs of Clojure
@i There's Akka / Okku and Quasar / Pulsar, I haven't used the latter so I can't tell you if one is better than the other.
i feel more like, a library will put too much constraints. actor, however, being a model, is a good pattern to follow.
Isn't that the point of these libraries, that they let you follow an actor model? Personally, I prefer to stick to core.async-style communicating sequential processes (CSP).
Maybe you can use akka from clj, I bet it's quite hairy but maybe interop is better nowadays
I sometimes see clojure code online that does this (,,,) at the end of expressions. What is the purpose of this?
I know they are essentially blanks, but why 3, why not just put nothing, or nil?
Used in examples as an ellipsis, a visual cue to indicate more forms may follow here
cf. http://blog.fogus.me/2013/09/04/a-ha-ha-ha-aah/ -- mentioned in the book "clojure applied" and called the "Fogus comma", apparently
I'm actually planning on finishing that book this week. Get a week off work so planning some book time
I found it interesting sisnce I only recently found it that it references schema, but then saw it hasn't had an edition update yet
for some reason cider repl not showing gui from swing i initialize it just returns object.. but normal repl outside works fine ,any1 had this problem?
@mirza are you using SwingUtilities/invokeLater to ensure you're on the swing thread when doing your swing calls ?
it has been years since i've done swing work, but i seem to remember that was a possible problem
it's good practice to always use invokeLater at the entry point of your swing calls anyways
e.g i want to define a function read-error
such that:
(let [ex (ex-info "top" {} (Exception. "root"))]
(= ex (read-error (pr-str ex))))
ex here is an ExceptionInfo object wrapping an Exception Object, so you are asking for a function that reads a printed exception string and makes an Exception object? what problem are you actually trying to solve?
I have a rest api that show the exception in the response body (printed as #error ...
) when an exception is thrown when it handles the request
i'd like to reconstruct the exceptions including causes, data etc, so i can rethrow it in the client, which lets me use cider's tooling to inspect the error
In general, a data conveying exception can contain references to mutable objects that are rife with issues if you attempt to serialize them between machines. Are you OK with such limitations?
yeah any limitations are fine, this is just for a quick and dirty debugging session
e.g. objects representing open files/network-connections, etc.
Ok, this avoids requiring a reader for 'tag which is nice, but is there a good way to convert this back to a throwable?
yes, but that is only on the server side, i'd like to transfer it to the client so i can rethrow it there
my client and server have the same code base, so if i could do something like
(let [response (call-server)]
(when (= 500 (:status response))
(throw (parse-error (:body response)))))
in the client, then i can use cider to inspect the stack trace and jump to the place that caused the errorwhile it's not impossible, I suspect making that work would be fairly tedious. in particular constructing the StackTraceElements
if you're going between jvms, you could just use Java serialization (but beware of having all the right classes in both jvms)
I've been down that road and it was full of all kinds of exciting pain
@chrisblom while not a Clojure specific solution, I wonder if it would be worth checking out Google Cloud's Debugger https://cloud.google.com/debugger/ - it allows you to inspect running code when an exception happens without performance impact. I haven't used it but sounds like might fit your requirements .
@chrisblom is it possible to just connect CIDER to your server?
don't know if this is a local dev server or 50 kubernetes managed servers though ๐
oh no, the server is actually running in the same jvm process. I was just curious if it was possible ๐
Sketch of rethrowing exceptions after tranfering them:
(import '[org.apache.commons.codec.binary Base64])
(defn- decode-str [s]
(Base64/decodeBase64 (.getBytes s)))
(defn- encode-str [bytes]
(String. (Base64/encodeBase64 bytes)))
(let [caught-exception (->> (Exception. "root" )
(Exception. "b")
(Exception. "a")
(ex-info "top" {}))
ex-response {:status 500
:body (-> (with-open [fos (java.io.ByteArrayOutputStream.)
oos (java.io.ObjectOutputStream. fos)]
(.writeObject oos caught-exception)
(.toByteArray fos))
encode-str)}]
(throw
(with-open [fos (java.io.ByteArrayInputStream. (decode-str (:body ex-response)))
oos (java.io.ObjectInputStream. fos)]
(.readObject oos))))
๐ Can anyone help me understand the behavior of auto-gensym when used in a function called from a macro? Details in snippet:
user=> (read-string "(defn whatever [] `s#)")
(defn whatever [] (quote s__3__auto__))
user=> (eval (read-string "(defn whatever [] `s#)"))
#'user/whatever
user=> (whatever)
s__6__auto__
user=> (whatever)
s__6__auto__
user=>
I think it won't cause a problem in practice, though, for the same reason that using a name in a let binding of a function body won't conflict across function calls.