Fork me on GitHub
#clojure-uk
<
2020-02-08
>
dharrigan07:02:19

Good Morning!

guy09:02:30

Morning!

cfeckardt22:02:22

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

seancorfield23:02:54

@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

cfeckardt09:02:31

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

seancorfield22:02:36

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

seancorfield22:02:19

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

seancorfield22:02:50

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.

wesley.hall11:02:19

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

cfeckardt08:02:04

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.