Plaster
New
List
Login
common-lisp
default
anonymous
2022.11.08 22:36:18
CL-USER> (progn (assert (null (probe-file #p"/tmp/doesnotexist"))) (block foo (with-open-file (stream #p"/tmp/doesnotexist" :if-does-not-exist :create :if-exists :append :element-type 'character :direction :output) (print 42 stream) (return-from foo) (print 42 stream))) (probe-file #p"/tmp/doesnotexist")) #P"/tmp/doesnotexist" #| CLHS Macro WITH-OPEN-FILE says: When control leaves the body, either normally or abnormally (such as by use of throw), the file is automatically closed. If a new output file is being written, and control leaves abnormally, the file is aborted and the file system is left, so far as possible, as if the file had never been opened. |#
Raw
Annotate
Repaste
Edit