title: Bind conditionally a dynamic var from Clojure's core for backwards compatibility
body: <p>I've been trying for a while to solve this <a href="https://github.com/nrepl/nrepl/issues/33" rel="nofollow noreferrer">nREPL ticket</a> and I'm out of ideas, so I decided to ask for a bit of help here.</p>
  
  <p>Basically we need to be bind <code>*print-namespace-maps*</code> only if it's present or find some way to define if it's not present that doesn't mess up Clojure 1.9+. </p>
  
  <p>Here are some of the things that don't work:</p>
  
  <pre><code>;; compilation error
  (when (resolve '*print-namespace-maps*)
    (set! *print-namespace-maps* (@bindings #'*print-namespace-maps*)))
  
  ;; shadows `clojure.core/*print-namespace-maps*` on 1.9, as the def gets executed always
  (when-not (resolve 'clojure.core/*print-namespace-maps*)
    (def ^:dynamic *print-namespace-maps*
      "Define the var for clojure versions below 1.9"
      nil))
  </code></pre>
  
  <p>Seems that dynamic vars can't be conditionally bound at all, which really sucks, but I guess there must be some way to do something like what we're aiming for. </p>
  
  <p>Take a look at the linked issue for more details. Any help would be much appreciated!</p>