Fork me on GitHub

(:import (org.apache.sshd.common.session SessionHeartbeatController$HeartbeatType))
;; or just
(:import org.apache.sshd.common.session.SessionHeartbeatController$HeartbeatType)
;; if you're only importing one class from that package


Can that alias just the inner class?

Alex Miller (Clojure team)02:10:06

in Java, inner classes are not hierarchically "below" inner classes, they are just lexically nested within them. The only hierarchical relationship is classes in packages.

Alex Miller (Clojure team)02:10:47

the class name of the nested class is SessionHeartbeatController$HeartbeatType so there is no way to break that apart


Oh I see. Thanks so much @alexmiller


Not sure if mostly Java related or Clojure, could guess Java/visualvm related but asking here just in case. Basically returning to my workstation today I find my project directory filled with *.class files, generated somehow. Guess it could be from a visualvm session yesterday with profiling?


That looks like AOT compilation- nothing to do with visualvm


hm, could not be happening when running the samples/profiles from visualvm?


Does this relatively new deprecation warning from Clojure tools WARNING: Use of :main-opts with -A is deprecated. Use -M instead. means that it is preferred to have $ clj -M:test:runner now instead of $ clj -A:test:runner -M:runner as described in

Adrian Smith09:10:17

Does anyone understand the mechanics of how this worked under the hood?, particularly viewing values inside of function calls


one of the neat things about lisps (including clojure) is that they typically have a small number of language primitives, . Not sure how Light Table did it, but you can basically just macro expand any form, look for the binding primitives (eg. let fn), and rewrite the code to extract the value when you eval the snippet


Ahhh, I see @seancorfield was updating the README of seancorfield/clj-new a few hours ago. I must have had the previous version open in my browser 🙂


@sztamas Yup, I'll be overhauling clj-new to favor the -X execution approach in the next release (while still retaining the -M stuff), but I wanted to get the README etc updated sooner (you'll see the same issue with projects generated from clj-new until I make that release).


Yes, thanks for that! The timing of it was a bit funny. I asked, then actually forked your project to make a PR with the README changes, but by then it all looked OK in my fork. Had a bit of a huh? moment... :-)


Is there a way to use with-redefs such that you wrap the root binding? For example:

(defn fake-invoke [arg]
  (println "HEY!")
  (original/invoke arg))

(with-redefs [original/invoke fake-invoke]
  (original/invoke "Something"))
This will cause a stack overflow because original/invoke is still rebound. I'd like to "escape" the rebinding in the fake-invoke call.


(let [original redefed] (with-redefs [redefed (fn new [...] (prn "intercepted) (original ...))

🙏 3

at my last job before with-redefs was added to clojure we had a macro with-var-roots that did the same thing, but had the added feature of being able to use metadata to ask that the original value of the var by bound to some name in the scope of the expression


(with-var-roots [^{:original foo} original/invoke (fn [arg] (println "HEY!") (foo arg))] (original/invoke "something"))
so you could do something like that

🙏 3

What do you think of reducible queue?

(defn reducible-queue [^BlockingQueue q]
  (reify IReduceInit
    (reduce [_ f init]
      (loop [acc init]
        (let [ret (f acc (.take q))]
          (if (reduced? ret)
            (recur ret)))))))

(let [q (doto (ArrayBlockingQueue. 1024)
          (.put 1)
          (.put 2))]
  (future (Thread/sleep 1000)
          (.put q 3))
  (transduce (take 3) conj [] (reducible-queue q)))
;; 1 second later:
=> [1 2 3]


Just reduce over the queue


You can already reduce over all java Collections and even all, I forget the interface iterables?

Jan K19:10:27

Reducing directly over the queue wouldn't wait for the last value 3. But it seems to me like (reducible-queue q) could be (repeatedly #(.take q))


oh, I haven't thought that queues are ordinary java collections


I wanted a reducible version for performance, I don't need intermediate collection...


hmm no, just reducing over queue does not block, that's not what I want


(let [q (doto (ArrayBlockingQueue. 1024)
          (.put 1)
          (.put 2))]
  (future (Thread/sleep 1000)
          (.put q 3))
  (transduce (take 3) conj [] q))
;; immediately
=> [1 2]


ah, you already pointed it out @jkr.sw 🙂

Jan K19:10:52

(into [] (take 3) (reducible-queue q)) would probably be even faster since it uses transients


yeah, true 🙂

Alex Miller (Clojure team)19:10:52

core.async has a reduce that reduces channels

Alex Miller (Clojure team)20:10:39

although I now feel like we've had this identical conversation already


don't remember it... I'm reluctant to depend on core async because of the startup time penalty it brings


this is for a library for others to depend on...


often you want to walk away from the queue based on an external signal, so continuous reduce might not be best thing


well that's what returning reduced is for?


e.g. (take-while (fn [_] @running)) is somewhere in xform


(no different with channels)

Matias Francisco Hernandez Arellano20:10:48

Hi folks. I was asked to write a little post about Clojure and one question I would love to answer is Why Clojure. To me was more curiosity than anything else... So wondering what is tour reason to choose Clojure over other functional or jvm languages (if this dont be long here just let me know Thabks)


I came to clojure because I read a bunch of blog posts saying lisps were cool. I stayed for the emphasis on programming with pure functions and ubiquitous use of immutable data structures.

💪 6

We like dogma and cults

😂 3
wizard 3
Adrian Smith21:10:13

Most languages ship dead fish binaries, old languages like lisp/smalltalk encourage you to REPL into your running programs to build up your programs at runtime, Clojure still has this ability This is game changing for debugging and building long running processes like web servers or LSP servers or video game creation


The question is fine here as long as folks stick to answering in this thread (otherwise, for a more wide-ranging discussion, I'd suggest #off-topic ). My answer to "Why Clojure" is based on my language arc: I'd done a fair bit of Lisp at university (in the early '80s) and I specialized in FP for my postgraduate work (ML, Miranda, SASL -- all precursors of Haskell, along with the research language I created: SURE). My early professional work was COBOL, C, and assembler, then on to C++ in '92 (and eight years on the ANSI Standards Committee), then Java in '97 -- and I liked the JVM so everything since has been JVM-based. CFML/ColdFusion while I was at Macromedia, alongside Java. Then Groovy, then Scala -- as I wanted to tie together my earlier FP work with something on the JVM. That was around 2009. That got me casting around for more FP options on the JVM so I found Clojure in 2010, then introduced it at work in 2011 and cross-trained the other developers. And I've been doing Clojure in production ever since. So, "Why Clojure" is: a) because I have always felt FP is a better way to design/construct programs (despite all my years in the OOP wilderness -- and a lot of advocacy for OOP, since I never figured FP would go "mainstream") b) because I like dynamic languages better than statically typed languages (mostly personal) and compile-on-demand languages better than aot-compiled languages (my laziness and lack of patience 🙂 ) c) because immutability by default eliminates a whole class of bugs d) because the REPL provides immediate feedback and an interactive way to build programs (again, my lack of patience 🙂 )

Matias Francisco Hernandez Arellano21:10:43

Thanks for the thorough answer


repl driven development support has also been a big reason I've stuck with clojure.

Matias Francisco Hernandez Arellano21:10:08

I still can't follow the idea of Repl DD haha.. good point


Eric Normand's REPL-Driven Development course on is awesome (if you don't mind paying $49 for a month's subscription). Stu Halloway has two great talks on the topic: Running With Scissors and REPL-Driven Development.


I've prattled on about it a lot too: never type instead of the REPL, don't use refresh/reload "magic", eval every single change as you make it (without even saving files), learn to run tests via the REPL using a hot key in your editor.


I started on BASIC, so the Lisp REPL was like coming home 🏠 after years of COBOL and C in tall buildings 🏢


The Clojure community is also great. Some attributes that come to mind: smart, humble, curious, thoughtful, generous, patient, welcoming.

💪 3

is there a transducer that does windowing by time? sort of like a partition-by, but flushes elements at least every n millis if non-empty


you can't do that with a transducer


the reducing function returns whatever value to a reducing context, and cannot wait for some timeout and flush


ah, good point