you are using an atom as a temporary variable. please don't do that.
(doseq [f files] (with-open [of (open-file f)] (do-dangerous-io of))) On Sun, Sep 13, 2009 at 1:05 PM, Constantine Vetoshev <gepar...@gmail.com> wrote: > > I have some code which opens a bunch of resources (say, files), and > needs to make sure they all get closed. Something like this: > > (let [files (atom [])] > (try > (open-my-many-files files) > ;; the files atom now refers to a vector of open file handles > (do-dangerous-io @files) > (finally > (doseq [file @files] > (.close file))))) > > The Clojure compiler does not like this: > error: java.lang.UnsupportedOperationException: Cannot recur from > catch/finally > > Does Clojure have a lower-level iteration primitive than loop and > recur, which I can use inside exception handling code? I can obviously > put a letfn inside the finally and use good old recursion, but I feel > uncomfortable doing this without TCO. (Yes, I know I'm likely to run > out of file descriptors before I run out of available stack frames, > but this is still the wrong way to do things.) I would also very much > prefer not to have to write and call out to Java helper classes for > something as trivial as a loop. > > > -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---