title: Can I avoid a second symbol lookup in Clojure resolve?
body: <p>I need to do a lot of string-to-symbol-value processing, but some of the strings will not resolve to symbols. I have written the following (example) code to test to see if a given string resolves to a known symbol, before dereferencing the var to get the symbol's value.</p>
  <pre><code>(if (resolve (symbol &quot;A&quot;)) @(resolve (symbol &quot;A&quot;))  ;; If the resolve of &quot;A&quot; works, deref it.
      false)                                          ;; If &quot;A&quot; doesn't resolve to a var, return false.
  </code></pre>
  <p>Maybe I think about things too much. I'm concerned about having to do the</p>
  <pre><code>(resolve (symbol &quot;A&quot;))
  </code></pre>
  <p>twice many times. Is there a clever way I can perform this &quot;test-for-nil-and-deref-it-if-not,&quot; only once? Maybe a &quot;safe&quot; deref function that doesn't generate a runtime error when dereferencing nil? Or should I just not worry about performance in this code? Maybe the compiler's clever?</p>