How do I use catch and throw in a macro? Here's a summary in the repl of what I have tried:
user=> (defmacro catch2 [class bind-var & body] `(catch ~class ~bind-var ~@body)) #'user/catch2 user=> (macroexpand-1 '(catch2 Exception e nil)) (catch Exception e nil) user=> (try nil (catch2 Exception e nil)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: catch in this context, compiling:(/tmp/form-init7515078331866806804.clj:1:10) Trying with explicit namespace on the catch: user=> (defmacro catch2 [class bind-var & body] `(clojure.core/catch ~class ~bind-var ~@body)) #'user/catch2 user=> (macroexpand-1 '(catch2 Exception e nil)) (clojure.core/catch Exception e nil) user=> (try nil (catch2 Exception e nil)) CompilerException java.lang.RuntimeException: No such var: clojure.core/catch, compiling:(/tmp/form-init7515078331866806804.clj:1:10) I have tried with clojure 1.8.0 and 1.9.0. Both have the same outcome. Can someone please point me to what I am doing wrong here, please? Thankyou Crispin -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
