Fork me on GitHub
#calva
<
2022-11-15
>
Yehonathan Sharvit01:11:36

What should I do after I remove a failing test to let Calva know that I don't want this test to run again? The problem is that even though the test is removed, it is still part of the run time!

bringe05:11:39

You can unmap the var with ns-unmap (I have not verified this) or you can use refresh or refresh-all from clojure.tools.namespace.repl.

seancorfield05:11:35

refresh is a serious sledgehammer to crack this sort of nut. ns-unmap is a reasonable option. @U0L91U7A8 also posted this question in another channel and got answers there too. My VS Code/Calva setup has a snippet to "clean" a namespace without actually deleting which I tend to use after reworking a test ns. It unmaps and unaliases and unrefers things, but is localized to that one ns.

bringe05:11:15

Oh I see. I use refresh regularly at least in one codebase I’ve been working in, but my work flow and the codebase may be fine to use it with, whereas maybe it doesn’t work well in other situations.

bringe06:11:24

What kind of issues could refresh cause? In my mind it keeps the runtime more in sync with the source during development.

seancorfield06:11:58

I see a lot of people get in trouble with refresh-based workflows, where they end up blowing away nses and not being able to get them to reload, or where they blow away some state and then no longer have a handle to shut stuff down, or some other failure mode -- and then they have to restart the REPL anyway. This Slack's full of reports of folks "breaking" their REPL with it. So I always discourage people from doing it. Use the simple, built-in tools instead of the opaque, black-box sledgehammers (like c.t.n.r).

Yehonathan Sharvit06:11:48

@U04V70XH6 Could you share your Calva snippet to "clean" a namespace?

seancorfield07:11:08

It's in my vs code calva setup repo on GitHub.

seancorfield07:11:36

I'm on my phone but you should be able to find it from that

bringe16:11:24

Thanks, @U04V70XH6. I think I know what you mean. The usefulness (or safeness) of refresh I think comes down to the structure of the code. I was having an issue like that before with refresh IIRC, which made me have to restart my repl (well, that was the easy solution) when it happened. I don’t have that problem in that codebase any more though. The key is making the code reloadable and making sure you can set up and tear down state via the repl. Of course, not every codebase is like this or really needs to be (I find it convenient, but it’s not a necessity), and some codebases might just have grown without that in mind, and retrofitting them isn’t feasible or ideal, so your advice makes sense in that light.

seancorfield16:11:17

It's kind of a "hot button" for me because I see people recommending it to beginners all the time without any discussion about alternatives or the downsides of that library -- and it frustrates me because I think it's better to teach beginners the "right way" to work in the REPL so they understand how to "undo" a definition and what can and cannot be easily redefined. I've haven't used c.t.n.r for many years -- I had some of those bad experiences with it early on -- and my REPL stays up and running for days (it gets restarted when my dev machine needs to be restarted -- which could be months, sometimes). And that's with a monorepo of 130K+ lines and over 100 subprojects (Polylith components).

skylize17:11:22

If you are still blogging, that could make a great post. Show us what is the "right" way, that all or mostly obviates the need for such tools. 😊🙏😊 A lot easier to point beginners to a nice blog post than code buried in "some guy's" 😉 rather complex Calva config. (The details are wrapped up inside Calva's API, which is wrapped inside VS Code's JSON API. And if not using VS Code, why would anyone be motivated to follow up on such a tip?)

seancorfield18:11:59

I've done a couple of videos showing my workflow (which doesn't involve c.t.n.r) and Rich, Stu, Alex, Eric Normand have all talked about their (similar) workflow that also doesn't involve c.t.n.r (Eric has a whole course on RDD where he specifically mentions not needing c.t.n.r in one lesson, as I recall). The blog post would be pretty short: "Don't use c.t.n.r 🙂 "

flowthing20:11:27

FWIW, I’ve heeded Sean’s advice regarding c.t.n.r and have come to wholeheartedly agree with it. I’ve come to think of c.t.n.r as mostly an optimization to restarting the REPL. With it, it’s easy to get used to a workflow where you make a change to a function somewhere in the depths of your program and reload the whole program, then wonder why it doesn’t work. Without it, you’re forced (in a good way) to make more focused changes, reload only the relevant parts of your app, and remain aware of how changes in one part of your program affect other parts. YMMV, obviously. 🙂

bringe03:11:15

Thanks for the responses. @U04V70XH6 Could you point me to one of your videos mentioned and/or that course by Eric? I’d like to look more into this. Maybe when I started to use c.t.n.r in this one particular codebase it was because I didn’t fully understand what was required to get my changes picked up by the running system. There’s a bit of wiring going on between different polylith components and integrant is involved to start certain stateful components. I may try not using it again - maybe now I’ll have a better idea of what’s required to load my changes properly.

bringe03:11:18

Although I’m also using integrant-repl for convenience and that uses c.t.n.r. 😄

seancorfield03:11:39

I'm on my phone, watching TV, but if you search for REPL driven development and either my name or Eric's name, you should be able to find them

pez09:11:45

Please share this video around if you find it useful. 🙏 ❤️ calva

👍 1
Kari Marttila17:11:53

Shared the video in Koodiklinikka Slack / clojure channel. Koodiklinikka is the main social media platform for Finnish programmers.

🙏 1
Kari Marttila17:11:26

You got in a couple minutes more thumbs in Koodiklinikka slack than in Clojurians slack: Maybe you should learn to speak Finnish and be active there. 🙂

1
Kari Marttila17:11:43

I have promoted Calva in Koodiklinikka slack. I really like Calva. Hopefully your user base will grow in Finland. 🙂

pez18:11:52

I’m so happy we have a user at Metosin!

Kari Marttila17:11:14

I noticed one strange behaviour when using Calva Paredit: Kill/Delete Right. | means the place of the cursor when applying Calva Paredit: Kill/Delete Right. 1.

(comment
  (+ 1 2 3 4 5)
  |
  
  )
2.
(comment
  (+ 1 2 3 4 5)
  |
  )
=> Nothing happens. 3.
(comment
  (+ 1 2 3 4 5)
  )
|
I.e. In the beginning there are two empty lines between (+ 1 2 3 4 5) and ) . The first time I apply Calva Paredit: Kill/Delete Right , it deletes one empty line (which is ok). I.e. the transition from 1 => 2. The second time (in position 2): nothing happens, which is a bit weird. Then I give the command again, and Calva deletes the last empty line, but the cursor jumps out of the form (2 => 3), which is also a bit weird. My Calva change log says that I'm using: [2.0.319] - 2022-11-10.

Kari Marttila17:11:46

A minor issue, but I thought you might be interested if this is some subtle bug.

pez17:11:07

I think it is some special RCF formatting. Try it with some other form and see if it behaves differently. Strange that it behaves differently on the second try, though, and buggy that the cursor jumps outside...

Kari Marttila17:11:41

Another example without comment block: 1.

(+ 1 2 3
   |
   
   4 5)
2.
(+ 1 2 3
   |   
   4 5)
=> Nothing happens the first time. 3.
(+ 1 2 3
  | 4 5)
A bit same behaviour in that sense, that nothing happens the first time in number 2. But the second time the cursor stays in the form in the right place.

Kari Marttila17:11:44

A minor nuisance, as I said. Just reporting if you are interested if this is something that needs to be investigated. I can create a ticket about this if you want.

pez18:11:52

Please report it. Wether someone finds it worth finding is another matter.