ClojureScript macro error: "Can't def ns-qualified name"

clojure, clojurescript

Solution

`htrhrthtrh` gets namespace-qualified by syntax-quote in the output, so the result looks like

(defn some.namespace/htrhrthtrh [] (js/alert "hi"))

which is incorrect, as explained in the exception message.

Presumably you'll want to use `~name` in place of `htrhrthtrh` to include the name argument to `defn+` in the output; this, or anything along similar lines, would fix the problem. To hard-wire this exact name you'd have to say `~'htrhrthtrh`.

Problem

What's causing this error? ``` (defmacro defn+ [name & stmts] `(defn htrhrthtrh ~@stmts)) (defn+ init [] (js/alert "hi")) ``` -- ``` java.lang.AssertionError: Assert failed: Can't def ns-qualified name (not (namespace sym)) ```

Original source