Fork me on GitHub
Quentin Le Guennec07:07:47

Is there a way in cider, when using a library A in an application B, to modify the source code of A, eval the modification, and see that modification in B?


sesman-link-with-buffer (or its variants)


When performance tuning hot paths, is it worth extracting invocations of fns like constantly or fnil where possible?

(defn foo [coll]
  (->> (mapv (constantly nil) coll)

;; is this worth extracting on a hot path?

(let [->nil (constantly nil)]
  (defn foo [coll]
    (->> (mapv ->nil coll)


in the first example (constantly nil) is executed once. it is not on the hot path. So how you construct that function doesn’t impact performance

Ben Sless09:07:53

But it's called every time foo is called, so foo is called on the hotpath, the allocation and optimization of constantly nil can be measured If your path is really hot, you can provide an explicit arity constantly, which is less idiomatic but will avoid allocation for every call

Ben Sless09:07:22

because constantly takes [& args], so every call will do a little allocation


> which is less idiomatic Which is also debatable, even now. :) I remember partial and comp (outside of transducers) catching some flack from the maintainers, but I think constantly was also in there.


I would have thought you'd get a bigger impact switching to transducers rather than having a number of intermediate sequences. But isn't the only real answer "measure it and see"?


Thanks for the tips folks

Dave Russell10:07:01

Here's an interesting find today, in case it's useful to anyone 🙂 -- we used to use medley/map-vals but have since updated to update-vals from 1.11. Turns out they have different behaviour, namely that update-vals will convert a sorted map into an unsorted map:

user> (def m (sorted-map :a 0 :b 0))
;; => #'user/m
user> (type m)
;; => clojure.lang.PersistentTreeMap
user> (type (update-vals m inc))
;; => clojure.lang.PersistentArrayMap
user> (type (medley.core/map-vals inc m))
;; => clojure.lang.PersistentTreeMap

👍 2
🤯 1

That's an important gotcha - thanks for finding that! I used to use medley.core/map-vals a lot too. Will try to remember this one.


i'm not surprised, sorted maps seem like they are for debugging


also, your update function can throw errors on a sorted map, which for me is the common case. every time i use sorted maps they make my program explode in some way.


@U01BP1CB37B could you perhaps submit a question on ? I think it would be useful to clarify whether this is the intended behavior or not.

Dave Russell08:07:53

Sure thing :thumbsup:


I’ve got a namespace

(ns foo (:require [ns-1 :refer [Foo]]))
and need/want to change it to
(ns foo (:require [ns-2 :refer [Foo]]))
ns-unalias seems not equipped for the job. Is there any way to remove this binding on Foo so I can reestablish it without restarting the repl? Solved: ns-unmap . I always forget to (apropos "ns") to find that helpful bit. (thanks @ghadi)


You might find inspiration in my "clean ns" REPL snippet for Calva:


i need to figure out a way to get a snippet system like that into inf-clojure. Also love the recursive taps


I probably don't need the outer tap> but all my snippets start with a call to tap> and at least this means something gets tap'd when it is done.


I wish snippets let you use actual code or at least multi-line strings (or maybe JSON does and I just don't know how? No, it doesn't 😞 )


> I wish snippets let you use actual code - @U04V70XH6 You might be interested in this.


@U90R0EPHA I already use Joyride (my vscode config repo on GH has my Joyride scripts in it), but custom REPL snippets auto-sync across machines whereas Joyride scripts do not 🙂


See for scripts that open Clojure or Java documentation directly inside VS Code


aliases are :as use ns-unmap for refers

👍 2

For a more brute solution, I sometimes use remove-ns and reload the whole ns