This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # asami (3)
- # babashka (3)
- # beginners (45)
- # boot (3)
- # calva (6)
- # clojure (26)
- # clojure-dev (16)
- # clojure-europe (15)
- # clojure-norway (6)
- # clojure-uk (6)
- # clojurescript (34)
- # community-development (4)
- # conjure (3)
- # datascript (4)
- # datomic (4)
- # emacs (21)
- # events (1)
- # fulcro (16)
- # graalvm (5)
- # jackdaw (1)
- # kaocha (5)
- # lsp (74)
- # malli (8)
- # nbb (37)
- # off-topic (50)
- # pathom (5)
- # reagent (19)
- # ring (1)
- # shadow-cljs (60)
- # sql (3)
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?
When performance tuning hot paths, is it worth extracting invocations of fns like
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
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
> which is less idiomatic
Which is also debatable, even now. :) I remember
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"?
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
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.
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.
I’ve got a namespace
and need/want to change it to
(ns foo (:require [ns-1 :refer [Foo]]))
(ns foo (:require [ns-2 :refer [Foo]]))
ns-unaliasseems not equipped for the job. Is there any way to remove this binding on
Fooso 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: https://github.com/seancorfield/vscode-calva-setup/blob/develop/settings.json#L222
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 😞 )
@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 https://github.com/seancorfield/vscode-calva-setup/tree/develop/joyride/scripts for scripts that open Clojure or Java documentation directly inside VS Code