One thing to consider: try* is a compiler builtin form. Those are currently
not even namespaced. That might lead to confusion for readers.


2013/6/20 Max Gonzih <gon...@gmail.com>

> I updated my macro to your solution, looks really simple and works like
> before. I don't know why I overcomplicated my original solution so much :).
>
> Thanks again!
>
>
> On Thursday, June 20, 2013 8:47:37 AM UTC+3, Meikel Brandmeyer (kotarak)
> wrote:
>>
>> Hi,
>>
>> Am Mittwoch, 19. Juni 2013 17:00:17 UTC+2 schrieb Max Gonzih:
>>>
>>> Hi, I implemented small macro to catch multiple exception classes with
>>> one body.
>>>
>>> https://gist.github.com/**Gonzih/5814945<https://gist.github.com/Gonzih/5814945>
>>>
>>> What do you think? Are there better ways to achieve similar results?
>>>
>>>
>> I would just extend try a simply as possible: simply add the catch-all,
>> but keep catch and finally as is. Here my try:
>>
>>     (defmacro try*
>>       [& body]
>>       (let [catch-all?   #(and (seq? %) (= (first %) 'catch-all))
>>             expand-catch (fn [[_catch-all exceptions & catch-tail]]
>>                            (map #(list* 'catch % catch-tail) exceptions))
>>             transform    (fn [form]
>>                            (if (catch-all? form)
>>                              (expand-catch form)
>>                              [form]))]
>>         (cons `try (mapcat transform body))))
>>
>>     (try*
>>       (println :a)
>>       (println :b)
>>       (catch-all [A B C] e (println (type e)))
>>       (catch D _ (println "Got D!"))
>>       (finally (println "Finally!")))
>>
>> expands to
>>
>>     (try
>>       (println :a)
>>       (println :b)
>>       (catch A e (println (type e)))
>>       (catch B e (println (type e)))
>>       (catch C e (println (type e)))
>>       (catch D _ (println "Got D!"))
>>       (finally (println "Finally!")))
>>
>> Kind regards
>> Meikel
>>
>  --
> --
> 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
> ---
> 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 clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to