Fork me on GitHub

Good Morning!




TIL that *ns* is only set under certain circumstances (like running code in a repl) .. so code that is evaluated in the repl may not run in gen-class'd (or from nrepl.cmdline) unless you explicitly bind it in your thread (for example in-ns). very confusing


@cfeckardt My tip: add

(def my-ns *ns*)
at the top of a namespace where you need to reference the namespace reliably and then you can use my-ns. That avoids the ways that *ns* is rebound differently between compilation and runtime


thanks. I needed to call tools.namespace.repl/refresh, but was unable to under some circumstances. I just wrapped my call in (binding [*ns* 'clojure.core] (.../refresh ...)) and it works


Life is often a lot simpler if you adopt an RDD workflow that doesn't depend on refresh/reload 🙂


Eric Normand talks about that in his RDD course (well worth a month's subscription to just for that course alone) and Stu Halloway has touched on this in a couple of his talks and podcast appearances.


I never use any sort of refresh/reload workflow. I've seen too many people run into problems with it -- and back when I did try it, I also saw "inexplicable" failures -- so I've just developed a workflow (like Eric and Stu, it seems) where I just don't need it.


@ You just sold me a subscription. Time to collect your commission 😉


I think that refresh call is just a relic from olden days. I use cider-refresh-after-fn mostly to reset the application state (like open database connections) managed by mount/component as needed. The repl/refresh call came for free as it was already there.