Actually, the for didn't work for me either but I believe that was a
lazy evaluation issue. The doseq seems to use internal recursion,
which breaks the try/finally. My final solution was to build up doseq
functionality with reduce. See below:
(defn foo1 []
(try
(println "body")
(finally
(doseq [x (range 3)] (println x)))))
(defn foo2 []
(try
(println "body")
(finally
(for [x (range 3)] (println x)))))
(defn foo3 []
(try
(println "body")
(finally
(reduce (fn [y x] (println x)) () (range 3)))))
- The foo1 definition can't be evaluated b/c of
java.lang.UnsupportedOperationException: Cannot recur from catch/
finally
user=> (foo2)
body
nil
user=> (foo3)
body
0
1
2
nil
--
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