Fork me on GitHub

there is no reliable way to stop a thread (including future-cancel) from another thread, without the thread co-operating (like polling the atom)


(reliable here being the operative word, future-cancel relies on the interrupted flag being set, the stop methods on threads is deprecated because it is "inherently unsafe")


that use thread pool than you use shutdown for it


shutdown a threadpool generally does not stop the threads if they are actively doing something, it waits for them to stop


but if is this needed in my program? What do you sugest to use?


kill all threads suddenly


Don't write programs that need that


Hi guys, quick qn, as a beginner should I try using kee-frame or use reframe directly? o:


#java-interop Hello, how to invoke default constructor of java class? such as Company(); which is not explicitly defined. thanks.


If the class declares any constructors then it won't get a default constructor, otherwise the default constructor is invokable just like any other


FYI We are starting to host the  apropos-clojure  live stream on Discord as of the next episode on Wed 30th Oct 2000 CEST Here is an invite link that will not expire: We will continue posting the recordings on YouTube for folks that can't or don't want to join live.

Jim Newton08:09:37

I have a question about slack. I get a message like this.

Jim Newton08:09:51

What should I do if I don't want notifications, and don't want it to keep asking me? I don't want to click the button to find out, because that will enable notifications.


You can disable them completely in Preferences


(if you are using the desktop client)


If you're using a browser, there should be an option in your peferences too, in order to disable notifications. I use Firefox and it's in preferences#privacy

Jim Newton09:09:27

is the suggestions to disable all notifications from every tool. or should there be a preference in slack to disable notifications?

Jim Newton09:09:49

So I went into the preferences of slack, and I believe notifications were disabled. because I saw a big green button labeled [Enable Notifications]. I didn't see a button saying disable them. So I assume they were disabled. But to experiment I clicked Enable. Now this is what I see.

Jim Newton09:09:29

I don't want notifications enabled. but there's now no button to undo what I just did. :-(

Jim Newton09:09:49

What does the following error message mean?

expected: (rte-match (quote (:* (or Boolean Long))) [42 43 false])
  actual: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
 at clojure.lang.RT.seqFrom (
    clojure.lang.RT.seq (
    clojure.core$seq__5387.invokeStatic (core.clj:137)
    clojure.core$every_QMARK_.invokeStatic (core.clj:2679)
does it means that it is trying to convert an object whose type is clojure.lang.Symbol to ISeq? Or does it mean that it actually received the object clojure.lang.Symbol and cannot convert that? If it means the former, then it would be very nice if it would tell me which object it was trying to convert, so I can have a chance of finding that object in my code somewhere.

Jim Newton09:09:05

The problem is that this error seem to be happening in a piece of my error checking code anyway, I'm trying to detect some error condition and report it to the user. But it looks like I'm not doing a good job of detecting the error.

Jim Newton09:09:30

I found the problem and it is very strange. I had a method defined as follows:

(defmethod valid-type? 'or [[_or& others]]
  (every? valid-type? others))
I.e., I had forgotten the space before the &. Strange that nothing else warned me of this.

Jim Newton09:09:27

this caused the multi-method framework (or function calling framework) to try to destructure the calling form into [[a b]] rather than [[a & b]] . It would be nice if clojure would tell me in this case. Cannot destructure this-data using argument template [[_or& others]]

Jim Newton09:09:45

rather than java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol


you'll find unfortunately, for now, error messages are one of Clojure's worst warts / most common complaints, with many errors falling back all the way to very granular activities in the java that makes up the compiler and runtime of Clojure before some sort of exception is emitted, at which case the high level context of the error is often a good bit lost (with the example here being this error finally being triggered with the Clojure runtime tried to convert something invalidly into a seq). Granted, I'm trying to make sure this is the most accurate way to describe said issues


Learning to find the relevant part of a full JVM stack trace is a useful skill, although one that appears daunting at first.


As a fellow Common Lisper, I feel your pain. Clojure is as difficult with errors as CL is amazing. Hang in there, is all I can offer. 🤷

Jim Newton10:09:21

Question about gensym and macro variables. As I understand there's a trick/idiom in clojure macros to avoid having to use gensym . Can someone suggest the idiomatic way to eliminate the gensym in this macro?

(defmacro destructuring-case
  "After evaluating the expression (only once) determine whether its return value
  conforms to any of the given lambda lists and type restrictions.  If so,
  bind the variables as if by let, and evaluate the corresponding form."
  [expr & triples]
  (if (not= 0 (mod (count triples) 3))
    (throw (ex-info (cl-format false "destructuring-case expects multiple of 3 number of arguments after the first: not ~A, ~A"
                               (count triples) (apply list 'destructuring-case expr triples))
                    {:error-type :invalid-destructuring-case-call-site
                     :expr expr
                     :triples triples}))
    (let [var (gensym "v")]
      (letfn [(conv-1-case-clause [[lambda-list types-map consequence]]
                (assert (map? types-map)
                        (cl-format false "destructuring-case expecting a map, not ~A" types-map))
                [(lambda-list-to-rte lambda-list types-map)
                 `(let [~lambda-list ~var]
        (let [triples (partition 3 triples)
              cases (mapcat conv-1-case-clause triples)]
          `(let [~var ~expr]
             (rte-case ~var ~@cases (:* :sigma) nil)))))))


The technique of using syntax-quoted expressions that contain symbol names ending in a # character can often be used to avoid calling gensym, but there are still macros where that technique does not work, and so gensym exists.


It appears that your macro has two syntax-quoted expressions, and one of them is intended to be used as a subexpression in the other? If so, then I believe that the symbol# technique only works within a single syntax-quoted expression, so your code cannot be mechanically converted into one that does not use gensym, and might require gensym

Jim Newton11:09:22

I want to concat two maps. doesn't say whether the first map or the second has priority. At least I didn't see where it explains.


merge might be a better choice here

Jim Newton11:09:28

oh I see, concat does not give me a map. rather it gives me a sequence with duplication. So I have to convert it into a map

Jim Newton11:09:32

merge might be interesting.


...sanity check 😃 java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long means that... it's expecting a sequence but got a number?


How can I check if a nested val in an atom is not yet set ?


(empty?) apparently not cool


maybe (not (contains? ... )) ?


Here's the offending lines

(if (empty? (get-in @users-atom [email :streak-count])) ;;fill  in a zero for streak count in case one doesn't exist
																						 			    (swap! users-atom assoc-in [email :streak-count] 0))
but this is not the idiomatic way to ask if a nested value is not-yet-set... how to does?


(def a (atom {"" {}}))
  (swap! a update-in ["" :streak-count] (fnil inc 0))

🎯 3
🎵 3

I just want to zero it out in this case... maybe (constantly 0) ?


if you want to set it regardless then (swap! a assoc-in ["" :streak-count] 0) should work, no?


oh well my problem is actually testing if it is set or not


maybe if (not (number? ...


so if it’s there, do nothing, if it’s not set it to zero?


but i think i could avoid this line completely with (fnil inc 0) !


however for the time being (not (number? )) seems to do the trick.


does it make sense to have :streak-count set to 0 as default, when you create your user?


@schmee it does and that is the current implementation, but some users predate this variable, so i have to conditionally add it

👍 3