title: ClojureScript Macro Gone Awry
body: <p><strong>Goal:</strong> I'm trying to make a macro which takes as an input something like the following:</p>
  
  <pre><code>(cb-chan (.readFile "/path/to/file" "utf8" _))
  </code></pre>
  
  <p>and returns as an output something like the following:</p>
  
  <pre><code>(go (let [c (chan 1)
            rep (.readFile "path/to/file" "utf8" (&gt;? c)]  ; &gt;? is a function that I defined elsewhere that jams the result of a callback into a channel
       rep
       (&lt;! c))))
  </code></pre>
  
  <p>Notice that the <code>_</code> in the original input is being replaced by special callback (defined elsewhere). This callback jams its result into a channel, which is then retrieved and returned at end of the go block.</p>
  
  <p><strong>Attempt:</strong></p>
  
  <pre><code>(defmacro cb-chan [func]
     `(cljs.core.async.macros/go 
        (let [~'c    (cljs.core.async/chan 1)]
             ~'rep  (replace (quote {~'_ (cljs-async-patterns.core/&gt;? ~'c) }) (quote ~func))
  
         ~'rep
         (~'&lt;! ~'c))))
  </code></pre>
  
  <p><strong>Result:</strong> This fails since <code>rep</code> is just ends up being a literal, unevaluated list. If I were able to type <code>(eval rep)</code> on the second to last line instead of just <code>rep</code>, my problem would be fixed, but I cannot since I'm working in ClojureScript (where there is no eval). How do I get around this?</p>