Error formatting macro: pagetree: java.lang.NullPointerException

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


  • investigate interaction with fork/join
  • new protocol or IFn for bits of cleanup logic placed in a scope
    • handling Closeable and IFn in an if statement for now
    • code in core happens before protocols are available
  • verify that change to with-open is non-breaking for existing code


  1. Creating a resource whose lifetime is bounded to yours: use with-open, as you do today
  2. Creating a resource that will be passed back to a caller unconsumed: call (scope res)
    1. caller must have made a scope
    2. mandatory scope is not a limitation here, it is a sensible requirement
  3. Returning >1 resources from a function with different lifecycles and cleanup rules: not supported
    1. not going to worry about this without realistic example
  4. Consuming one resource, pass another through to caller: put with-open around the one you are consuming
    Code Block
    ;; a cleaned up here, b cleaned up by caller
    (let [a (with-open [a ...] ...
          b (scope ...)]
  5. Decide on the fly whether to clean up or let parent do it
    Code Block
    ;; capture-scope? grab-scope? capture-cleanup?
    (let [[a s] (capture-scope (make-a))]
      (if (done? ...)
        (s) ;; cleanup myself
        (scope s) ;; punt