dev-tooling

mauricio.szabo 2023-07-28T20:49:54.445679Z

A question: if I connect to nrepl and basically send the form: (do (ns new-ns) (pr-str (defn a-fun []))), what should be the result? I thought it was going to be "#'new-ns/a-fun" (basically, a-fun gets created in new-ns) but it seems that the result is actually ""#'user/a-fun" (or whatever namespace the REPL was before). Is that right?

2023-07-28T21:16:27.981699Z

I just run that on my cider repl, and looking at the nrepl log looks like it return the expected thing "#'new-ns/a-fun"

mauricio.szabo 2023-07-28T21:35:18.587299Z

Yeah, you're right. I found the offending code (I was wrapping around some stuff): This fails for me: {:result (do (ns aaa-some-new-ns) (pr-str (defn a-fun [])))}

2023-07-28T21:37:04.671939Z

yeah, but that seems to be a Clojure thing:

$ clj
Clojure 1.11.1

user=> {:result (do (ns aaa-some-new-ns) (pr-str (defn a-fun [])))}
{:result "#'user/a-fun"}

aaa-some-new-ns=> 

mauricio.szabo 2023-07-28T21:57:52.644999Z

So that reproduces 😢. Sad that's a Clojure thing...

2023-07-28T22:05:48.839729Z

yeah, it is interesting how this two things behave :

clj -e "(do (ns aaa-some-new-ns) (defn a-fun []))"
#'aaa-some-new-ns/a-fun

clj -e "[(do (ns aaa-some-new-ns) (defn a-fun []))]"
[#'user/a-fun]

2023-07-28T22:06:30.570169Z

looks like it takes a different path in the compiler

borkdude 2023-07-28T22:49:39.620699Z

this has to do with top level do being unnested

mauricio.szabo 2023-07-29T00:19:33.452739Z

BTW, lumo fails on both (do (ns...) and [(do (ns... and Babashka/nbb passes on both 😄

👍 1
mauricio.szabo 2023-07-28T20:55:10.458179Z

(This for Clojure - Babashka does what I expected, and returns "#'new-ns/a-fun"