On 21 Feb, 14:27, Lee Spector <lspec...@hampshire.edu> wrote:
> On Feb 20, 2011, at 5:27 AM, FD wrote:
>
>
>
> > Is there something similar to the lisp macro ignore-errors (http://
> >www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_ignore...)
>
> I use this:
>
> (defmacro ignore-errors
>   "Returns the result of evaluating e, or nil if it throws an exception."
>   [e]
>   `(try ~e (catch java.lang.Exception _# nil)))

You should be careful with such a thing. I don't know Clojure's
internals, but there's the possibility that it's using exceptions to
model certain kinds of control transfer; on the other hand, not all
Throwables are Exceptions, they can be Errors too: should ignore-
errors swallow StackOverflowError or not?

-- 
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