So, I have a macro that looks something like this:

(defmacro test-failure
  [& forms]
  `(handler-case :type
     ~@forms
     (~'handle :error/error
       (println "error happened"))))


(My real macro is more complex, but this gives the idea.)

If I eval

 (test-failure (println "test"))

I get:

 => Unable to resolve symbol: handle in this context

However, if I macroexpand-1 the thing, I get:

 (macroexpand-1 '(test-failure (println "test")))

 => (clojure.contrib.condition/handler-case :type (println "test") (handle 
:error/error (clojure.core/println "error happened")))

That is correct, and if I eval just that it works fine.

Here is an interesting thing:  if I do this:

 (macroexpand '(test-failure (println "test")))

I get

 => (try (println "test") (handle :error/error (clojure.core/println "error 
happened")) (catch clojure.contrib.condition.Condition c__19__auto__ 
(clojure.core/binding [clojure.contrib.condition/*condition-object* 
c__19__auto__ clojure.contrib.condition/*condition* (clojure.core/meta 
c__19__auto__) clojure.contrib.condition/*selector* (:type (clojure.core/meta 
c__19__auto__))] (clojure.core/cond :else (clojure.contrib.condition/raise)))))

It's expanded the handler-case part, but the "handle" is still there.  That 
seems wrong to me.

I've tried lots of different ways to specify handle besides ~'handle, but they 
all seem to fail.

Any suggestions?





-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to