I have a function foo which uses tail recursion:

(defn foo [] .... (recur))

I need to do some clean-up work after foo (there is an external
binding that requires some post-foo processing), and this needs to
happen even if foo fails. The naive approach was:

(try (foo)
  (finally (clean-up))

However, foo recurs and you can't recur in a try/catch/finally.
(java.lang.UnsupportedOperationException: Cannot recur from catch/
finally)

So, my question is: does anyone have a pattern for exception checking
(this same issue would work if I just wanted to catch an exception in
foo) when the contents of the try block recur?

I could just remove the tail recursion and go for straight recursion
in foo, but there's got to be a better way...

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