Fork me on GitHub
Mark Addleman00:09:38

I'm using metosin's spec-tools (v0.10.0) for coercion. The following code snippet is not producing what I would expect:

    (st/spec {:spec (s/cat :op (st/spec {:spec keyword?}))})
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

Alex Miller (Clojure team)04:09:02

RT = runtime, and no, or not easily

Alex Miller (Clojure team)04:09:32

boot pods do give you some level of this and there are other libs that do this to some degree

Alex Miller (Clojure team)04:09:52

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


whereas it isn't required for other primitives like (+ 1 2 3) or (prn "Hello world")


(and obviously my fork copy will be missing all the previously launched threads)

Alex Miller (Clojure team)04:09:03

the RT does not run any threads - you run the threads :)

Alex Miller (Clojure team)04:09:57

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

Alex Miller (Clojure team)04:09:22

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


Does anyone now a simple way to have 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)
user=> (.toString e)
"clojure.lang.ExceptionInfo: message {:data 123}"


I assume there's some way to customize how logback emits exceptions.


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 (of which I have an updated version on Github somewhere)


not sure what your use case is


Nice, ill take a look


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:


for the 4clojure kind of use case, eventually sci may also be used: that could even run client-side and server-side


but it's not on par with everything that is needed in 4clojure solutions probably


Ah... here’s where I was reading about 4clojure progress:


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


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...)


I used claypoole in other project, I´ll try to use with it too


Hey people who have used another languages to create API's, is the term "handler" something common ?


Quick google for "request handler" seems to point at "yes" as the answer 😉


Why does iterate’s docstring say that f must be free of side-effects?

Alex Miller (Clojure team)21:09:52

because it doesn't make any promises about when f is called, or how many times its called

Alex Miller (Clojure team)21:09:51

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

Alex Miller (Clojure team)21:09:36

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

Alex Miller (Clojure team)21:09:35

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?

Alex Miller (Clojure team)21:09:35

yep, but we took advantage of it when iterate was reworked in 1.7

Alex Miller (Clojure team)21:09:27

I also did a lot of review of 100s of existing uses of it

Alex Miller (Clojure team)21:09:54

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

hiredman22:09:29 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"

Alex Miller (Clojure team)23:09:33

it is something I frequently forget, then remember :)