/[cmucl]/src/code/macros.lisp
ViewVC logotype

Diff of /src/code/macros.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.111 by cshapiro, Thu Jan 3 11:41:51 2008 UTC revision 1.112 by rtoy, Thu Jun 19 22:20:12 2008 UTC
# Line 1543  Line 1543 
1543    
1544    
1545  ;;;; With-XXX  ;;;; With-XXX
1546  (defmacro with-open-file ((var &rest open-args) &parse-body (forms decls))  (defmacro with-open-file ((var filespec &rest open-args) &parse-body (forms decls))
1547    "Bindspec is of the form (Stream File-Name . Options).  The file whose    "The file whose name is Filespec is opened using the Open-args and
1548     name is File-Name is opened using the Options and bound to the variable    bound to the variable Var. If the call to open is unsuccessful, the
1549     Stream. If the call to open is unsuccessful, the forms are not    forms are not evaluated.  The Forms are executed, and when they
1550     evaluated.  The Forms are executed, and when they    terminate, normally or otherwise, the file is closed."
    terminate, normally or otherwise, the file is closed."  
1551    (let ((abortp (gensym)))    (let ((abortp (gensym)))
1552      `(let ((,var (open ,@open-args))      `(let ((,var (open ,filespec ,@open-args))
1553             (,abortp t))             (,abortp t))
1554         ,@decls         ,@decls
1555         (unwind-protect         (unwind-protect
1556             (multiple-value-prog1              (multiple-value-prog1
1557                 (progn ,@forms)                  (progn ,@forms)
1558               (setq ,abortp nil))                (setq ,abortp nil))
1559           (when ,var           (when ,var
1560             (close ,var :abort ,abortp))))))             (close ,var :abort ,abortp))))))
1561    
# Line 1571  Line 1570 
1570         ,@decls         ,@decls
1571         (unwind-protect         (unwind-protect
1572           (multiple-value-prog1           (multiple-value-prog1
1573            (progn ,@forms)              (progn ,@forms)
1574            (setq ,abortp nil))            (setq ,abortp nil))
1575           (when ,var           (when ,var
1576             (close ,var :abort ,abortp))))))             (close ,var :abort ,abortp))))))

Legend:
Removed from v.1.111  
changed lines
  Added in v.1.112

  ViewVC Help
Powered by ViewVC 1.1.5