I'm working on module that may use a number of different backends, some of which may keep open files across a number of API calls. Other backends may not use files at all. Like
(backend-init) ; opens some files, opaque to the caller (backend-do-something); uses the open files (backend-finish); close the files Off-hand, I don't see a way to structure code like this to use with-open, since the backend would lose its open files when returning from any with-open it might do. Am I approaching this the wrong way? Is there a standard way of structuring code like this? It's a bit like the backend is itself the resource to be opened (under the hood would be opening multiple files). I saw a thread about making a "close" multimethod that sounded related. Also, when the backend is opening files it will need to catch errors and close any opened files (e.g. if the second open fails, close the first), which is a bit like with-open, except it would call "close" only on error. Is this an existing method or idiom for this? I guess one alternative is to pass a body to be executed to the backend, so the backend can wrap it in with-open. -- -- 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.