This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-09
Channels
- # announcements (5)
- # beginners (53)
- # clj-kondo (4)
- # cljdoc (3)
- # cljs-dev (11)
- # cljsjs (1)
- # clojure (59)
- # clojure-europe (15)
- # clojure-italy (6)
- # clojure-nl (9)
- # clojure-spec (22)
- # clojure-uk (26)
- # clojurescript (16)
- # clojutre (6)
- # cursive (27)
- # datomic (34)
- # duct (1)
- # figwheel-main (2)
- # fulcro (12)
- # graphql (14)
- # jackdaw (9)
- # jobs (1)
- # kaocha (4)
- # luminus (1)
- # off-topic (11)
- # pathom (1)
- # pedestal (2)
- # re-frame (6)
- # reagent (10)
- # ring-swagger (34)
- # shadow-cljs (47)
- # spacemacs (21)
- # sql (3)
- # tools-deps (37)
- # uncomplicate (11)
- # vim (17)
I'm using metosin's spec-tools (v0.10.0) for coercion. The following code snippet is not producing what I would expect:
(st/coerce
(st/spec {:spec (s/cat :op (st/spec {:spec keyword?}))})
["a"]
st/string-transformer)
Yields ["a"]
- I was expected [:a]
Does spec-tools support s/cat
and the spec regular expressions?in clojure/java interop, does the RT in clojure.lang.RT = runtime? Is there any way to have 2 or more distinct clojure runtimes going at once in clojure itself, or in java? Essentially, I want to "boot" a clean clojure instance with nothing initialized in one
RT = runtime, and no, or not easily
boot pods do give you some level of this and there are other libs that do this to some degree
you really need at least classloader isolation
thanks - is there a good spot to look at the launch point/source code of any threads a clojure RT has executing? (what threads does it run, and is it possible to manually invoke them?) I'm not making a "production" solution, just having some fun tinkering with clojure/java/jni and forking at a C level. I'm as far as passing an arbitrary fn to to the forked jvm and getting the result back to the parent via external means (file etc.), however in my fork of the JVM, any calls to clojure.core/eval, whether executed directly from RT in java, or via my IFn.invoke() passed in function, it will break there
i'm assuming something runs in the clojure runtime that is required for calls to "eval" to work on the java/jvm side
the RT does not run any threads - you run the threads :)
well, I guess future and agent do use thread pools for execution, so those and things that rely on them (like pmap) do potentially start threads
but the RT is mostly started by loading the RT class via the different entry points
@m131 you might be interested in shimdandy, which I recently played with and updated a library to make very easy to use https://github.com/SevereOverfl0w/clj-embed
Does anyone now a simple way to have clojure.tools.logging
log the ex-data when backed by logback? (It’s just logging the message and the stacktrace)
I vaguely recall this being an issue of logback's implementation specifically calling .getMessage
. Calling .toString
would have included the ex-data.
user=> (ex-info "message" {:data 123})
...
user=> (.getMessage e)
"message"
user=> (.toString e)
"clojure.lang.ExceptionInfo: message {:data 123}"
You can configure it but to my knowledge only the size of the stacktrace printed.
Ok, there is ThrowableHandlingConverter 🙂
why doesn't string/index-of
have a ^long
return type hint? because that's not possible with primitives maybe?
@m131 @dominicm depending on the use case, there's also https://github.com/Raynes/clojail (of which I have an updated version on Github somewhere)
I remember reading that someone was looking at bringing 4clojure up to date but needed to update clojail, @borkdude do you think your update might do the trick? Or maybe your clj-embed @dominicm?
@lee I used clojail to run code from clojuredocs to verify specs in speculative: https://github.com/borkdude/speculative/blob/master/deps.edn#L15
so the fork is this one: https://github.com/borkdude/clojail
for the 4clojure kind of use case, eventually sci may also be used: https://github.com/borkdude/sci/ that could even run client-side and server-side
Ah... here’s where I was reading about 4clojure progress: https://github.com/clj-commons/meta/issues/2
Hello all, I´m building clojure program to process video stream into many ways. I want to distribute this each frame to many processing specific processors, like one for saving it to database, other for doing some OCR, other to detect objects in image, and so one ... How do you think it´s the best way doing this? core.async? Producer->Consumer events? ReactiveX?
core.async isn't good for directly using with IO or CPU intensive tasks (but you can use it in combo with the core.async/thread macro to avoid the issue), I think the simplest answer here is a concurrent queue plus threadpool, eg. what an ExecutorService provides
use core.async if there are complex coordination conditions to implement after the parallel processing completes
Claypoole is incredibly useful for creating threaded code, avoids diving into ExecutorService https://github.com/TheClimateCorporation/claypoole
does it have a queue mechanism? I've used it for "pmap" type stuff but not that
the docs make me think you'd need to pretend your requests / tasks were a lazy-seq, that's an antipattern
I think Claypoole's pmap is ordered, as it also has a upmap variant (order by whoever returns first)
right, but it consumes a seq, that's the problem to me
(the ordering aspect is a smaller problem)
Right. I guess it was never an issue in our use case, as we use it for parallelizing IO operations
maybe one of these weekends I'll make a PR on claypoole for a queue based parallelization that handles eg. binding conveyance etc. (which is where executorservice becomes less convenient if you need it...)
Hey people who have used another languages to create API's, is the term "handler" something common ?
good to know
Why does iterate
’s docstring say that f
must be free of side-effects?
because it doesn't make any promises about when f is called, or how many times its called
a particularly subtle aspect is that the return value from iterate is actually both seqable and reducible and the latter does not use any cached values of the seqable
it's pretty unusual to use the result in both contexts (usually you do one or the other) but you could construct some pretty weird results in combination with side-effecting functions
if you want to do this with side-effecting things, repeatedly
or run!
are prob better
the docstring has been like this since at least 2009, when reducible wasn't a concept yet?
yep, but we took advantage of it when iterate was reworked in 1.7
I also did a lot of review of 100s of existing uses of it
to convince myself that people largely did as they were commanded :)
(let [stuff (iterate #(do (println 'N %) (inc %)) 0)] (println (doall (take 5 stuff))) (reduce (fn [n i] (if (< 5 i) (reduced n) (+ n i))) 0 stuff))
N 0
N 1
N 2
N 3
(0 1 2 3 4)
N 0
N 1
N 2
N 3
N 4
N 5
15
user=>
🙂https://clojure.atlassian.net/browse/CLJ-1906 is somewhat related to iterate, in that when you state the problem a common refrain is "just use iterate" and then you have to say "oh, but iterate's doc says no side effects"
it is something I frequently forget, then remember :)