This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-13
Channels
- # aleph (7)
- # announcements (3)
- # babashka (29)
- # beginners (70)
- # calva (5)
- # cider (14)
- # clara (3)
- # clj-kondo (25)
- # cljs-dev (2)
- # clojure (237)
- # clojure-conj (3)
- # clojure-europe (6)
- # clojure-italy (14)
- # clojure-nl (4)
- # clojure-uk (40)
- # clojurescript (29)
- # clojurex (1)
- # code-reviews (2)
- # cursive (3)
- # datascript (1)
- # fulcro (11)
- # graalvm (4)
- # graphql (12)
- # jackdaw (1)
- # jobs (1)
- # joker (22)
- # london-clojurians (1)
- # off-topic (132)
- # re-frame (38)
- # rewrite-clj (11)
- # shadow-cljs (200)
- # spacemacs (1)
- # sql (67)
- # tools-deps (15)
Hi all, I'm looking to contribute to some beginner friendly open source clojure projects, I've gone through the brave clojure list and though there are some beginner friendly issues, I don't know where to start
Is it required that I read much of the source code and understand it before contributing?
well, it depends. but in general you probably should have a good grasp on what the project does to be able to make a good contribution.
Hi, everyone
How can I have a drop in repl (like browse
in R lang) for debug in clojure?
@U6CE37RK6 sounds like you're looking for a Socket Repl?
Thanks @seancorfield Do you have a link or code example on how to do it?
I wanna make it part of my workflow (I use spacemacs + cider)
(Should I use clojure.core.server/start-server
?)
You can start a socket repl with just a JVM option when you start your application. You can then connect to it via telnet or netcat. Our use unravel / unrepl for a better experience.
Cider requires NREPL
When you talk about spacemacs/CIDER, that sounds like a regular development workflow which is always REPL-based in Clojure
So maybe I'm confused about what you're asking?
maybe the key thing with "browse" is that it drops you into the context of the error, with the locals and stack frames available? that's not really how things work in clojure normally but there was at least once a debug-repl for this sort of functionality https://stat.ethz.ch/R-manual/R-devel/library/base/html/browser.html
@U6CE37RK6 maybe to move up a level, what we usually do instead is isolate state and mutation, so that as much as possible can be debugged standalone
Thanks @seancorfield , yeah I already use the repl all the time, and what I was looking for was exactly what @noisesmith mentioned : to be dropped into the context and be able to access locals and stack frames.
Thanks a lot @noisesmith, the debug-repl you mentioned by @U0GN0S72R appears to be exactly what I was looking for.
Also thanks for your advice. But I have a question about it. I do try to isolate state and mutation yet I still find such functionality useful ... to use it when you’re probing the system for sth or ... e.g. when a generative test fails and it’s not able to shrink it properly. What’s the best way to debug then ? Thanks again @noisesmith
glad I could assist, mutation in order to track local data is actually useful (and isn't neccessarily subject to the same problems that mixing side effects with app logic can be) - eg. you can add (def debug (atom []))
at the top level and something like (swap! debug conj {:context ::some-context :args [arg1 arg2] :locals {:a a :b b}})
inside the function you are debugging - it's like println debugging except you can actually play with the data, even if the issue comes up every Nth invocation
but the more principled you are about isolating side effects and logic, the more likely something like that is actually useful (eg. not relying on state of some fd or resource that is closed on error or exit)
Any better way of associating a variable using update-in
than using constantly
? The reason I don't use assoc-in
instead is because it's intended to be used with lein update-in
. Here's what I got:
(update-in {} [:local-repo] (constantly ".m2"))
Actually scratch that, using constantly doesn't work, so a better question would be, how to change lein :local-repo
using the command line? This doesn't work:
lein update-in :local-repo '(constantly ".m2")' -- deps
Well, is there a lein assoc-in?
I am using chime to heartbeat via async-http request like documented here: https://github.com/jarohen/chime#chime-ch
now I need to find a way to return the channel so that I can close it when needed. the example just runs and I cannot stop it gracefully. any ideas?
my first idea is that you return a function closed on it when you create it so you can call that when you want to close it
(let [chimes (chime-ch ,,,)]
(<!! ,,,)
(fn stop-chiming []
(close! chimes)))
if you use mount state then
(defstate chimer
:start
(let [chimes (chime-ch ,,,)]
(<!! ,,,)
chimes)
:stop
(close! chimer))
is there a preferred method to open a file at a given byte? I don't know Java well.
Like this: https://docs.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html ?
that might be correct, I only need to read the file. Is this a use Java interop
situation?
here's a good example https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-11_random-access-files.asciidoc
is there a way to prevent backtick quoting from adding the namespace?
example
(ns test-ns)
(defn get-vec `[?foo ?bar])
(get-vec)
=> [test-ns/?foo test-ns/?bar]
;;I want that to return
;;=> [?foo ?bar]
What does everyone use instead of async-await in cljs? Need to make a few calls to js libraries and want to avoid callback hell. I don't seem to be able to find tutorials
sounds like promesa
might solve this! https://blog.jeaye.com/2017/09/30/clojurescript-promesa/
and mentioned at the bottom of that blogpost is cljs-promises which make a promise more like an async channel
The problem with that tutorial is that it seems out of date. Promesa doesn't have p/await
Also kitchen-async https://github.com/athos/kitchen-async
I know what I am going to ask below is very vague question, sorry for that. But if you have any points for me to check will greatly help. I get the below exception: clojure.lang.ArityException: Wrong number of args (3) passed to: core$not This started coming after I added new argument for the existing function in both Java class and also in clojure reify where ever it is used. Any suggestions/ideas to fix this issue will be helpful. Thank you!
Do you know how to show stack traces for exceptions?
I tried the below in my .clj file. But it doesn't print stacktrace in the log file. (catch Exception e (logger/error (str "failure " ) e) (clojure.stacktrace/print-cause-trace e)) could you please tell me how I can enable full stack trace in clojure?
They can be long, and contain things you can safely ignore, and it takes some practice to read them, but they can give valuable clues.
@sreerama.naga Sounds like you have code that calls not
like this: (not a b c)
instead of (not a)
(single argument). Perhaps when editing the code to add a new argument, you ended up moving a )
?
Hello! What is the best book to learn Clojure? I work with Java and I have experience with Scala, but i want to learn a pure functional lang. Thanks!
Hard to say what is the best. I like "Clojure Programming" by Emerick, Grand, and Carper, but published in 2012 so while much of it still works just fine, you may want something more recent like "Programming Clojure" by Miller, Halloway, and Bedra, 2018.
Joy of Clojure
Manning? @U1RCQD0UE
Thanks!
It describes how http requests can be mapped to functions that take maps in one format and return maps in another format
Jetty is a webserver for which the ring project ships an adapter for (most other adapters are maintained outside of the ring project)
so it sounds like if i wanted to learn about how to tune a jetty server for production load, it would be more of a jvm question than clj
It depends, as an abstraction ring has some costs, and depending on your analysis you might decide things will perform better without the adapter and speaking to jetty directly from clojure
I think it would start as more of a jetty question (jetty has pretty extensive docs), and then maybe move to the jvm, then maybe looking at the costs of ring
Thanks @seancorfield , yeah I already use the repl all the time, and what I was looking for was exactly what @noisesmith mentioned : to be dropped into the context and be able to access locals and stack frames.