Skip to content

Instantly share code, notes, and snippets.

@kiras
Created September 11, 2010 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiras/575669 to your computer and use it in GitHub Desktop.
Save kiras/575669 to your computer and use it in GitHub Desktop.
(defn close-files [col]
(println "closing files...")
(map #(.close %) col))
(defn -main [& args]
(let [files (ref (list))]
(try
;; User can open files (in which case they will be added to the files list),
;; work on them, close them (in which case they should be removed from the
;; files list), etc.
(finally
;; Ideally the program should not exit without prompting the user about
;; whether to save files and would probably end up closing them earlier,
;; but this should ensure that the files are closed eventually.
(close-files @files)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment