Is it based on http://dev.clojure.org/display/design/Resource+Scopes ?
On Friday, October 11, 2013 3:54:59 PM UTC+2, Paul Stadig wrote: > > It separates the resource management from the creation and lexical binding > of resources. You can create a scope high up in the call stack, and within > the dynamic extent of that scope you can create resources, return them from > functions and freely use them; when the scope eventually exits, then the > resources will be cleaned up. > > This library does also generalize a bit to allow you to register an object > and a clean up function, or even just a thunk to get called when the scope > exits. > > On Friday, October 11, 2013 7:56:52 AM UTC-4, Cedric Greevey wrote: >> >> What does this do that (with-open ...) doesn't do? Generalize to other >> cleanup methods than (.close x)? >> >> >> On Fri, Oct 11, 2013 at 6:36 AM, Paul Stadig <pa...@stadig.name> wrote: >> >>> I have released version 0.1.0 of scopes, a little library for resource >>> scopes. It can be used to establish a resource scope with the >>> with-resource-scope macro. Within the dynamic extent of that macro one can >>> register a resource with the scoped! function so that when the macrco block >>> goes out of scope .close is called on the registered resource. >>> >>> An object and function can also be registered with (scoped! x (fn [x] >>> ...)) so that when the macro block goes out of scope the function will be >>> called and given x as an argument. >>> >>> There is also a shorthand function called scoped-thunk! that will >>> register a thunk (a function taking no arguments) to be called when the >>> macro block goes out of scope. >>> >>> The scopes library also defines a function named closeable? that will >>> return true if its argument implements java.lang.AutoCloseable. >>> >>> Because scopes uses the java.lang.AutoCloseable interface and the >>> exception supression mechanism, it is only compatible with Java 7. >>> >>> Finally, there is also a scopes-magic artifact, and when it is on the >>> classpath it will automatically pull in the scopes library and add >>> with-resource-scope, scoped!, scoped-thunk!, and closeable? to clojure.core >>> so that they are automatically available everywhere with out having to be >>> imported. I'm not saying that this is necessarily a good idea, but there it >>> is. :) >>> >>> https://clojars.org/pjstadig/scopes >>> https://clojars.org/pjstadig/scopes-magic >>> >>> >>> Paul >>> >>> -- >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- -- 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.