This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-16
Channels
- # atlanta-clojurians (1)
- # aws (1)
- # beginners (65)
- # boot (4)
- # cider (81)
- # cljs-dev (25)
- # cljsrn (27)
- # clojure (129)
- # clojure-dusseldorf (12)
- # clojure-italy (68)
- # clojure-norway (5)
- # clojure-poland (4)
- # clojure-spec (14)
- # clojure-uk (72)
- # clojurescript (144)
- # code-reviews (19)
- # copenhagen-clojurians (5)
- # cursive (16)
- # datomic (21)
- # editors (1)
- # emacs (15)
- # events (1)
- # figwheel (6)
- # fulcro (54)
- # graphql (1)
- # hoplon (24)
- # jobs (6)
- # jobs-discuss (2)
- # keechma (4)
- # leiningen (6)
- # luminus (17)
- # lumo (2)
- # off-topic (43)
- # onyx (6)
- # pedestal (2)
- # perun (2)
- # portkey (3)
- # re-frame (22)
- # reagent (11)
- # ring-swagger (5)
- # shadow-cljs (46)
- # specter (8)
- # test-check (2)
- # testing (3)
- # vim (16)
- # yada (1)
Reading about transducer, it seems it's a powerful way to write composition of map
and its siblings. And it's also better in terms of performance compared with the lazy-way ->>
. So when do you NOT want to use transducer, other than when dealing with infinite sequence?
transducers can also be used with infinite sequences:
=> (transduce (comp (filter odd?) (take 10)) conj (range))
[1 3 5 7 9 11 13 15 17 19]
the only reason to use the normal sequence functions over their transducer variants is convenience
hi guys, I'm puzzled by defonce
- why isn't it thread safe?
- is there a thread safe equivalent of it?
agreed with this quote from that log: "defonce at runtime shouldn't happen"
@funyako.funyao156 In my experience a transducer may not be the best option if the sequences you are processing over are small (flat, ~6 items or less). based on some naive but simple benchmarking of into {} (remove (comp nil? second) {:a 1 :b b :c cl
}` and merge {:a 1} (when b {:b b}) (when c {:c c})
also nothing special at 6 items, just an arbirary size at which point I started to notice the runtimes tending to favor transduce
Hi. I have a situation where I need to pass an arg (a path) to a function about 15 levels down the call chain. For aesthetic reasons I don't want to add an extra arg to all fns down. Is there a known pattern I could use for this? I'm currently considering using an atom, with-redefs or alter-var-root, but they seem kinda heavy handed.
Ended up using (def path ^:dynamic nil)
and (binding [path "blah"] ...)
in the top level fn. Seems like a lighter approach compared to the others.
This could be somewhat fragile as now the function depends on the context it's run in, not only its input. Also the caller needs to know that you need to bind that variable and that is not explicit.
putting def inside a function is a problem also
Does path
have a sensible default value? FWIW Zach Tellman’s Elements of Clojure treats this subject explicitly and the key difference between what he suggests and what you’ve done here is to take in the value of path
as a param to the top-level fn and use that param in the binding
call
In this way, you’re using a bound var where you want it, but the value of that bound var is still expressed in terms of input, rather than being a magic number somewhere in your code. You can still test the fn 15 calls down by wrapping your tests in (binding [*path* "/path/to/test/data"] ...)
Thanks for the replies and sorry if I wasn't clear enough. The def path
is top level, the lower level fn is using this def, and the binding
is being set in the main fn from an arg that it receives from the external caller. I think this is what @U07HA15PY recommends as well.
@U485ZRA58 Thanks for the warning. I'm ok with the function being dependent on the context for now, since it's already an internal fn quite deep inside the ns. Nobody should be using it standalone. If that happens, I could update it to be able to receive the path as argument.
it's pretty dead, the author is now working on another thing - http://witheve.com/
which is also pretty dead at this point https://github.com/witheve/Eve > This repository hosts a preview of Eve v0.3 alpha, which is no longer under active development.
it's so dead it has become the standard reference for dead applications, now you can say "my side project lighttabled"
@U9QTVPNHX cider with emacs?
Proto REPL plugin for http://atom.io is easy to setup too
In spacemacs, using evil mode (vi compatilbility), I find I'm having to create an extra space at the end of a sexp just to evaluate it with ", e e". Is there a way without having to append that extra space (cummulatively, it's a big time waster)
@UA2UNSUGZ it's at the end of the line, right? move to the beginning of the next line :)
@UA2UNSUGZ Add this line into your config file - (setq evil-move-cursor-back nil)
inside of spacemacs/user-config
Thanks guys! To the OP, might want to keep an eye on the progress of Visual Studio Code clojure plugins too.
@U96AF7MHP Chris Granger had some comments on lighttable that might interest you: https://groups.google.com/forum/#!msg/light-table-discussion/2csnnNA1pfo/693EWDJVhuwJ
I'm having difficulties to figure out how to send JSON Web Token as part of a GET method using cljs-ajax. Something like: (ajax-core/GET url { :format :json :response-format :json :headers { "Accept" "application/json" "Content-Type" "application/json" "Authorization" base64-decoded-token } :handler -handler :error-handler -error-handler } ) For some reason if I add the "Authorization" header it messes the CORS in the backend side. Is there some way to print the actual request ajax-core is sending (like using curl -v (verbose))?
are you in a browser @kari.marttila?
Yes. And the Rubber Duck effect seems to be working since I guess I already figured out the problem right after writing the previous post. 🙂 I had to add the "Authorization" header to the allowed headers in my cors handler. Damn. 🙂
I should buy a real rubber duck, put it on my table and explain the problem to it before I post my questions in this forum. 🙂
open this slack, tick the "Offline" checkbox in devtools, and just write your message as usual
Thanks for that hint. I'm now examining the http requests in Chrome developer tools / Network tab. I'm an old backend developer and trying to learn some frontend skills using ClojureScript.
it was partially joking, but I'm glad it was a useful hint 🙂
It was a good hint. I was watching the Console tab in browser and as an old backend developer I was thinking the obvious solution: log the http request in code somehow. I didn't realize that there it was all the time in Developer tools / Network tab. 🙂
it's an amazing tool. you can filter and replay requests. also works for websockets
Ok. Thanks for sharing that info. I need to check it out in more detail once I have more time.
How worthwhile is learning typed clojure as a beginner? Will I notice a lot of benefits using it early on or am I better off using regular clojure first?
rather than splitting the timeline between compile <---> runtime, spec allows you to split it in a different way: development time <--> production time
There is also an effort to do static checking https://github.com/arohner/spectrum
https://www.youtube.com/watch?v=VNTQ-M_uSo8 @stuarthalloway has a great presentation where he hits on the dynamic vs. static stuff in the first <15 min
I'm having a weird problem starting my compojure app in the repl https://www.reddit.com/r/Clojure/comments/8cs5hg/what_does_self_referential_dependency_mean_and/
FYI, if you suspect a cyclic dependency is a problem in the future, starting a Clojure/Java REPL and doing (require '[http://some.name.space]) will fail with a list of all namespaces found in a cyclic dependency chain, as long as one is found by require'ing http://some.name.space and all namespaces that it use's or require's, transitively.
Eastwood can also detect cyclic dependencies, but it seems will only tell you 2 of the namespaces in the cycle (even if the cycle has more than 2 namespaces in it). Still helps narrow it down.