Skip to content
Snippets Groups Projects
Commit 07b7746a authored by ram's avatar ram
Browse files

.../systems-work/code/macros.lisp, 10-Feb-90 13:06:45, Edit by MBB.

  WITH-OUTPUT-TO-STRING-APPEND-STYLE:
  Changed the doc-string to exploit the new standard that was already there.

  WITH-OPEN-FILE-DOES-NOT-EXIST:
  Modified WITH-OPEN-FILE to not execute the body when OPEN fails.  This is
  the new standard.
parent cc57ed31
No related branches found
No related tags found
No related merge requests found
......@@ -1336,22 +1336,24 @@
;;;; With-XXX
(defmacro with-open-file ((var &rest open-args) &body (forms decls))
"Bindspec is of the form (Stream File-Name . Options). The file whose name
is File-Name is opened using the Options and bound to the variable Stream.
The Forms are executed, and when they terminate, normally or otherwise,
the file is closed."
"Bindspec is of the form (Stream File-Name . Options). The file whose
name is File-Name is opened using the Options and bound to the variable
Stream. If the call to open is unsuccessful, the forms are not
evaluated. The Forms are executed, and when they terminate, normally or
otherwise, the file is closed."
(let ((abortp (gensym)))
`(let ((,var (open ,@open-args))
(,abortp t))
,@decls
(unwind-protect
(multiple-value-prog1
(progn ,@forms)
(setq ,abortp nil))
(when ,var
(when ,var
(unwind-protect
(multiple-value-prog1
(progn ,@forms)
(setq ,abortp nil))
(close ,var :abort ,abortp))))))
(defmacro with-open-stream ((var stream) &body (forms decls))
"The form stream should evaluate to a stream. VAR is bound
to the stream and the forms are evaluated as an implicit
......@@ -1383,8 +1385,9 @@
(defmacro with-output-to-string ((var &optional string) &body (forms decls))
"Binds the Var to a string output stream that puts characters into String
and executes the body. See manual for details."
"If *string* is specified, it must be a string with a fill pointer;
the output is incrementally appended to the string (as if by use of
VECTOR-PUSH-EXTEND)."
(if string
`(let ((,var (make-fill-pointer-output-stream ,string)))
,@decls
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment