Last active
October 23, 2018 03:39
-
-
Save Colelyman/1521aac0e2801be554b9817d9e4346d9 to your computer and use it in GitHub Desktop.
A Common Lisp macro that opens a file and closes it after some computation is done.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro open-file-defer-close (file-path file-handle &body body) | |
"Opens FILE-PATH as FILE-HANDLE, executes BODY and finally closes FILE-HANDLE." | |
`(let ((,file-handle ,(open file-path))) | |
,@body | |
(close ,file-handle))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment