title: how can macros be evaluated using the clojurescript repl
body: <p>Once the browser is connected to the clojurescript repl, I previously had no way of calling macros from the repl. This is an issue that has put me off clojurescript in the past, preferring using javascript directly. Basically, I felt that the cljs-repl was kinda lame and I was going back to the compile/debug cycle that writing code in clojure was supposed to emancipate us from.</p>
  
  <p>Are there any good workarounds/workflows for pushing and testing code in clojurescript? Especially if macros can be evaluated?</p>
  
  <p>An example of my problem is:</p>
  
  <ol>
  <li><p>make a new cljs project </p>
  
  <blockquote>
    <p>lein new cljs-template blah</p>
  </blockquote></li>
  <li><p>start up the server</p>
  
  <blockquote>
    <p>cd blah</p>
    
    <p>lein run</p>
  </blockquote></li>
  <li><p>run the web-repl</p>
  
  <blockquote>
    <p>lein trampoline cljsbuild repl-listen</p>
  </blockquote></li>
  <li><p>there is a file <code>src/blah/client/main.cljs</code> with the heading</p></li>
  </ol>
  
  <pre>
      (ns blad.client.main
        (:require [noir.cljs.client.watcher :as watcher]
                  [clojure.browser.repl :as repl]
                  [crate.core :as crate])
        (:use [jayq.core :only [$ append]])
        (:use-macros [crate.macros :only [defpartial]]))
  </pre>
  
  <p>notice the line <code>(:use-macros [crate.macros :only [defpartial]])</code> </p>
  
  <p>I can't use <code>defpartial</code> in the browser repl because it is a macro. The error I get is:</p>
  
  <pre>
  >> (crate.macros/defpartial [])
  "Error evaluating:" (crate.macros/defpartial []) :as "crate.macros.defpartial.call(null,cljs.core.Vector.fromArray([]));\n"
  #
  TypeError: Cannot read property 'defpartial' of undefined
  </pre>
  
  <p>Now defpartial is quite a useful macro and without it, it was a hassle.</p>
  
  <p>My problem got worse when i wanted to define another macro in the project with the <code>:use-macros</code>. I could not debug what i wrote at all in the repl or the browser and after about half a day, I figured out that it was quicker to use a clj repl, test the macro in there using macroexpand and the copy the results back into the browser repl. I got one cljs macro working after about a day it wasn't very fun. This was about 6 months ago. I'm hoping there is a quicker way to do this now.</p>