This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-06
Channels
- # babashka (101)
- # beginners (47)
- # biff (7)
- # calva (36)
- # clj-kondo (19)
- # clojure (11)
- # clojure-europe (1)
- # clojurescript (4)
- # conjure (4)
- # core-typed (3)
- # cursive (24)
- # emacs (22)
- # events (4)
- # gratitude (1)
- # introduce-yourself (1)
- # malli (27)
- # meander (5)
- # off-topic (101)
- # portal (5)
- # shadow-cljs (26)
- # tools-build (4)
- # tools-deps (3)
- # vim (8)
- # xtdb (13)
Should my workflow be save to editor and then Restart REPL? Or am I missing something fundamental?
Maybe not... I dunno, that restart REPL does feel like a heavy operation, but it kinda does what I expect
there are a few different ways people work (restarting the repl is not one of them)
some people only (or mostly) evaluate individual expressions from the editor
that page does not seem to cover that, but there are actions to evaluate the prior form at the cursor or top level form you're in
often people work like this in (comment ) blocks in the file they're in
other people tend to reload the current file as they edit (load file in repl) ... this is my typical mode of working. I'm not sure it's the best, but it is a habit I developed long ago
and then other people follow the mode of "refreshing" or "syncing" the repl by reloading all changed files. you might also see this called the "reloaded" pattern. Cursive's "Sync files in REPL" seems to be of this mode. I didn't even realize Cursive had that, but I've never used it.
typically I find that just reloading the current file is sufficient for me to have the repl runtime state "follow" my changes. there are a few well-known cases where the Clojure runtime stores things that can go stale - namely protocol and multimethod implementations, well and I guess things like defonce. if you are reloading a sufficient set of files and have a good mental model of how those work, you can avoid issues there. in last case, I'll restart.
I removed a function and added a dummy function called thing
, and when I did the sync files after removing it, it remained in the REPL. When I restarted the REPL, it was gone. That's what I'm noticing with sync files. Is that expected behavior? Because I, too, am banking on sync files to be the way to go, but that's strange behavior, and if I restart the REPL, I get what I expect
Also, perhaps in a larger project restarting the REPL would be a heavy operation, but it takes under a second in my toy situation at the moment
Load file in REPL also keeps removed functions. Perhaps that makes sense to people and I just need to change my expectation?
In the case of changing an implementation, I confirm that both sync and load do reflect those changes. So maybe it's not an issue
that is expected - the clojure runtime stores state across the set of loaded namespaces, which have vars, which have state. syncing and reloading will re-populate that state, but won't generally remove it.
there are ways to remove vars, like (ns-unmap *ns* 'fn-to-remove)
the reloaded workflow actually unloads, then reloads to avoid this. generally, I do not find that to be worth doing. if I remove enough stuff that it's annoying me (like renaming a bunch of tests), then I'll restart the repl
Related; is there a nice way to list what's loaded and, crucially, when it was loaded in? I tend to use re-run last test in repl a lot, and it does seem to sometimes miss things. At the minute I just restart repl if things seem off, but if there's a way to avoid that it would be great
So, yes I have. What’s holding me back at the moment is that the build of the doc is very complicated. Maintaining the screenshots was a nightmare, so I now script and automate the IDE to take them, and take them with a frankentool which calls Apple APIs directly. So now it’s a different sort of nightmare 🙂