Re: Strange behaviour of *standard-output* in sbcl



Nikodemus Siivola <nikodemus@xxxxxxxxxxxxxxxx> writes:

On Jul 30, 5:34 pm, Joshua Taylor <joshuaaa...@xxxxxxxxx> wrote:

This suggests that WITH-OPEN-FILE could be implemented as

(defmacro with-open-file2 ((var filename &rest options) &body body)
`(with-open-stream (,var (open ,filename ,@options))
,@body))

This is not interrupt safe: if an asynch unwind occurs after open, but
before the UNWIND-PROTECT from W-O-S has been entered, the file will
be left open. (Ok, there is no guarantee that WITH-OPEN-FILE is async
signal safe -- or indeed anything, but you can always hope.)

Who says WITH-OPEN-STREAM isn't defined as if by

(defmacro with-open-stream ((var form) &body body)
`(ext:without-interrupts
(let ((,var ,form))
(unwind-protect
(ext:allow-interrupts (progn ,@body))
(close ,var)))))

? (For suitable WITHOUT-INTERRUPTS and ALLOW-INTERRUPTS, of course.)

--
RmK
.