*
form*
→ result*
with-open-stream performs a series of operations on stream, returns a value, and then closes the stream.
var is bound to the value of stream, and then forms are executed as an implicit progn. stream is automatically closed on exit from with-open-stream, no matter whether the exit is normal or abnormal.
The stream has dynamic extent; its extent ends when the form is exited.
The consequences are undefined if an attempt is made to assign the the variable var with the forms.
(with-open-stream (s (make-string-input-stream "1 2 3 4")) (+ (read s) (read s) (read s)))
→6
The stream is closed (upon exit).
None.
None.
None.
\issue{DECLS-AND-DOC} \issue{WITH-OPEN-FILE-STREAM-EXTENT:DYNAMIC-EXTENT} \issue{WITH-OPEN-FILE-SETQ:EXPLICITLY-VAGUE}