This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-25
Channels
- # aleph (2)
- # announcements (7)
- # babashka (6)
- # beginners (53)
- # calva (17)
- # cider (5)
- # clj-kondo (137)
- # cljs-dev (19)
- # cljsrn (14)
- # clojure (74)
- # clojure-conj (9)
- # clojure-europe (13)
- # clojure-houston (1)
- # clojure-italy (16)
- # clojure-nl (21)
- # clojure-spec (3)
- # clojure-uk (9)
- # clojuredesign-podcast (24)
- # clojurescript (85)
- # cursive (11)
- # datomic (28)
- # duct (3)
- # emacs (6)
- # figwheel-main (1)
- # fulcro (68)
- # graalvm (19)
- # graphql (3)
- # joker (32)
- # kaocha (10)
- # lambdaisland (1)
- # malli (50)
- # off-topic (13)
- # other-languages (7)
- # pathom (2)
- # pedestal (14)
- # re-frame (53)
- # reitit (8)
- # shadow-cljs (57)
- # specter (2)
What's a clean way to fail the test suite (`lein test` ) if an auxiliary thread threw an exception? I tried:
(-> (reify Thread$UncaughtExceptionHandler
(uncaughtException [_ thread ex]
(is false (pr-str ex))))
(Thread/setDefaultUncaughtExceptionHandler))
however this doesn't fail the build. I do see FAIL in ()...
in stdout, but build passes.
I guess it's some sort of race condition, as the exception can happen between a test is finished and the next one is runIt isn't a race condition, the testing machinery makes use of dynamic bindings and the thread your exception handler is run on doesn't have the bindings setup to report a failure
yup, had guessed that was the case
Do you know of a (clean) fix that leverages these bindings?
Otherwise I think I settled for System/exit
within my DefaultUncaughtExceptionHandler
The best thing to do is to either test on the effects (if a background thread I supposed to write to the DB check the DB), or have other threads actually report their results instead of firing and forgetting
If you can get an exception in a random thread and it indicates a problem with your program. and you test suite doesn't fail except for watching specifically for exceptions in other random threads, it means you are missing a test for whatever the behavior of that thread was
Good observations! My intention was to have this a safeguard in my test setup, rather than use it actively as a means for coding sloppier tests This specific library has quite a lot of intrinsic concurrency (`go` blocks etc) so it seems particularly needed here
Fun fact:
(.toEpochMilli (java.time.Instant/MAX)) ;; => ArithmeticException: long overflow
Java FTW!This makes sense and is documented in the javadoc for .toEpochMilli
As I user I am surprised I can make Instant so far in the future that long cannot hold it 🙂
Thank you!
I am looking to write a clojure wrapper for a REST api. Does anyone have any examples of existing clojure wrappers that they find to be truly excellent in some way?
You want to create a Clojure client calling a remote REST? I would have a look at http://clojurewerkz.org/, I guess you find something inspiring there
thanks @U0522TWDA this is a great resource and I will take a look. Right now I’m browsing https://github.com/magnetcoop/payments.stripe
Hi, I am using clojurescript since 5 months. I am very happy with the experience. On server side I use Elixir. I think without knowing JavaScript using ClojureScript would be very very hard. Is it same for Clojure? Without knowing any Java can I handle Clojure or I better stay in Elixir&Erlang
I don't think you need to be an experienced Java developer to take advantage of Java libraries from Clojure. You do need to know how to find useful libraries, and read and interpret their API documentation, so you need at least some of the terminology of Java to be familiar and understood.
Same as https://elixirforum.com/t/must-i-learn-erlang-after-learning-elixir-can-i-learn-elixir-only/2069 I think
You’re able to use Erlang libraries from Elixir using native Elixir syntax quite easily, but you’ll need to learn Erlang syntax and semantics to read and understand Erlang API docs. Beyond that, I haven’t learned Erlang in full, and I haven’t had any issues using Elixir for everything. You mostly just need to know the mapping from Erlang to Elixir syntax.
I started Clojure at work with an Erlang background. Didn’t know much than that I disliked the JVM 🙂 But I totally switched. Today I love Clojure and benefit from the JVM. And you can come fairly far without having to deal too much with Java 🙂
Then I am going to give a deeper look 🙂 . I am in love with Erlang's BEAM but after getting used to lisp syntax I am missing it alot when I code in other languages.
Isn’t Elixir a LISP with a Ruby-ish syntax? 😛
this is eluding me this morning for some reason.. what would be preferable to (when [x (potentially-nil)] x)
?
or
? what you want to happen when it's nil?
I don't understand what you're asking for
that's no problem
Sounds like you may not need it, but it is possible to check for nil on a single item with some?
(which is different than some
for collections).
so are you specifically trying to avoid false
?
(if (false? x) nil x)
is that logically what you want?
actually.. man this is silly, i’m reading from a map and so it would of course be nil if it doesn’t exist.
On Java->Clojure interop and classloaders: If the Java environment requires that a specific classloader be set before calling Clojure, does that imply that we always need a "native" Java class definition to handle this as opposed to doing something like gen-class? Or is there some way to make this work in Clojure with no Java code?
I assume this refers to your prior questions about KSQL. Because that env seems to have some classloader expectations, I'm not sure that there is any way to avoid doing something in Java. But not knowing anything about their setup, it's hard to say.
They're isolating the classpaths for different user-defined functions in KSQL, so I'm guessing you're right, that the Java step is going to be required.
Howdy, How can I add more native threads (default 8 to my project?
threads for what?
how did you default them to 8? @contact904
core.async is by default using 8
@contact904 from https://clojure.github.io/core.async/ -
go blocks are dispatched over an internal thread pool, which defaults to 8 threads. The size of this pool can be modified using the Java system property `clojure.core.async.pool-size`.
there are cases when you want to up that, but more often if you have to up that it indicates an issue with your code
the pool size was deliberately made smaller to expose errors in using core.async that used to happen rarely during dev, then happen under load when deployed
it's better to rewrite your core.async code not to block the pooled threads
if you are just starting out with core.async you almost certainly do have places where you are doing blocking operations in go blocks
Likewise, setting the new flag seems recommendable (in :dev/:test builds, at the very least) https://github.com/clojure/core.async/commit/aca2b4caf195b668e0e5aba286345d5fa376b1fb#diff-04c6e90faac2675aa89e2176d2eec7d8R65
that's great, of course there are a lot of other ways to block, but that at least reduces the number of gotchas
it is wild to me how much demand there is for some lightweight way to make ns aliases to make namespaced keywords shorter to type
@sogaiu So there is something shorter than this:
(alias 'm (create-ns 'ws.domain.member))
No, but people think :ws.domain.member/my-symbol
is too long
and they want an easier way to alias ws.domain.member
to m
than the code I gave.
And being able to change the alias
line once per namespace is less work (and less error prone) than changing every reference to a keyword with that qualifier...
::
is fine. I use it a lot with specs.