Fork me on GitHub
#clojure
<
2023-10-05
>
flowthing06:10:58

What is the purpose of https://github.com/clojure/clojure/blob/b1b88dd25373a86e41310a525a21b497799dbbf2/src/clj/clojure/main.clj#L412-L413 in clojure.main/repl? If I implement my own version of clojure.main/repl, should that version do the same thing?

phill10:10:21

Clojure's classloader looks for .clj files and compiles them when needed. I think you will need it. Passing the (prior) classloader to it as a parameter enables it to extend, as it were, whatever the prior classloader chain had been doing.

flowthing10:10:49

I phrased my original question badly. I've been using a custom REPL implementation that retains the classloader of the original REPL for years without any ill effects. I've only ever started that custom implementation from within an existing clojure.main REPL, though. Now that I think about it, maybe installing a new classloader is only relevant in cases where it's necessary to return to the original, top-level REPL. I'm still not sure in what practical reason there is for installing a new classloader for each nested REPL.

vemv14:10:19

It seems cautious to at least make sure that the parent CL is a DynamicClassLoader, and not a default one. But yeah avoiding an abundance of CLs is a good idea, nREPL does that

flowthing14:10:23

Oh yeah, you're right, that's probably what that's about: ensuring that the context classloader is a DynamicClassLoader. πŸ‘ Since I know I'm always going to be on top of a clojure.main REPL, I probably don't need to do that.

πŸ™Œ 1
seancorfield15:10:31

When I was using the Socket REPL Server (and Chlorine/Clover for my editor integrations), it did not use a DCL by default so you couldn't add new dependencies to the running REPL -- so I had an alias that enabled a DCL like that code in clojure.main/repl when starting a Socket REPL Server.

πŸ‘ 2
seancorfield15:10:59

(and also lines 62-63 of dev/repl.clj in the diff block just below that)

jwhitlark18:10:28

If anyone would like to try using Clojure and emacs with https://containers.dev/, I've written up rough instructions on my https://github.com/jwhitlark/cnc-devcontainer-templates repl https://github.com/jwhitlark/cnc-devcontainer-templates/issues/3 . I'd be grateful for verification/corrections if I've made any mistakes with this part. If you want to just use it with vscode, I've got a number of samples in the repo (single container, multiple containers, k8s). It's stuff I now use everyday, but I'd be interested in feedback to document it better or add additional features.

Carsten Behring20:10:45

I am interested in Clojure in devcontainers, when using Clojure with python / R . I am wondering which advantage devcontainer in a pure Clojure project bring. Can you explain a bit your use case ?

jwhitlark22:10:31

I work on a number of different projects, frequently with others. Devcontainers give you a clean and common environment, that can still be customized, by running one command. Rather than documentation that drifts out of date, and everyone with a different setup, you can all have a copy of the same system, while still being able to customize it.

jwhitlark22:10:18

Especially as a project grows and acquires tools and scripts, it makes it worlds easier to collaborate.

jwhitlark22:10:34

Much of what I've learned is just trial and error, so I'm trying to document it so that people don't have to rediscover the wheel each time.

jwhitlark22:10:32

It is also super handy to experiment with new libraries, as you can setup sample data, which lowers friction with people just getting started.

Adam Helins20:10:31

It seems clojure.pprint/pprint is not quite deterministic regarding how qualified keywords in maps are printed. E.g. One machine might print {:mvn/version "1.11.1"} whereas another one might print #:mvn{:version "1.11.1"}, which messes with CI in my case. Is there a way to force one or the other? πŸ™

Darin Douglass20:10:45

<https://clojuredocs.org/clojure.core/*print-namespace-maps*|https://clojuredocs.org/clojure.core/>*<https://clojuredocs.org/clojure.core/*print-namespace-maps*|print-namespace-maps>*

Darin Douglass20:10:39

What you’re seeing is likely an nrepl / middleware thing

ghadi20:10:50

why does it matter if they're equivalent?

☝️ 2
Adam Helins20:10:14

@U02EA2T7FEH It's odd, I'm running the same command from the terminal in all machines, no REPL involved, even using Nix to homogenize the env :thinking_face: @U050ECB92 I have a very simple task that compares files by textual representation and I'd like to keep it that simple

cjohansen21:10:42

They're not really equivalent though, namespace maps are completely unreadable

ghadi21:10:55

they're not edn readable, but they are clojure-reader readable

cjohansen21:10:08

Yeah, sorry, this was a very personal opinion, not relevant to the topic.

ghadi21:10:13

yeah I don't enjoy them myself, but I couldn't tell what your angle was from your comment πŸ™‚

hiredman21:10:39

I would be very surprised if this was the case. My suspicion is that the differences in the printing of the maps arises due to some other difference between your local machine and ci

πŸ‘ 1
hiredman21:10:35

like that is the kind of thing that would make me worried the ci server is using a different set of deps for some reason

Adam Helins07:10:04

@U05VAB0RW4C Interesting alternative, I'll give it a go @U0NCTKEV8 It must be, but it is far from obvious (even more so that we are using Nix for having a reproducible env) :thinking_face: Well I suppose the easiest fix is to systematically bind *print-namespace-maps*, it's just slightly suboptimal πŸ™‚

flowthing08:10:57

pp won't make a difference here; it obeys *print-namespace-maps* the same as clojure.pprint/pprint.

flowthing08:10:02

Can you share the CLI invocation / code you're using where you see this inconsistent behavior?

Adam Helins12:10:31

@U4ZDX466T I'm simply invoking a function as a Babashka task which does some data manipulations and eventually pprint the output. @U04V15CAJ I don't suppose Babashka does anything special with *print-namespace-maps*?

borkdude13:10:49

Of course there could be an inconsistency somewhere in bb vs clj. Feel free to provide a repro when you find one