~ chicken-r7rs (master) bcac12d62686b967eeb3f4889d77fc51ba7efc96


commit bcac12d62686b967eeb3f4889d77fc51ba7efc96
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Thu May 30 09:23:59 2013 +0000
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Thu May 30 09:23:59 2013 +0000

    call-with-port, close-port & eof-object

diff --git a/r7rs.scm b/r7rs.scm
index ae86f7b..619c2aa 100644
--- a/r7rs.scm
+++ b/r7rs.scm
@@ -12,6 +12,10 @@
  error-object-irritants
  read-error?
  file-error?
+ ;; Input & output
+ call-with-port
+ close-port
+ eof-object
  ;; System interface
  command-line
  exit
@@ -161,6 +165,23 @@
        (and (exn? obj)
             (file? obj))))))
 
+;;;
+;;; 6.13. Input and Output
+;;;
+
+(define (call-with-port port proc)
+  (dynamic-wind void (lambda () (proc port)) (lambda () (close-port port))))
+
+(define (close-port port)
+  (cond ((input-port? port)
+         (close-input-port port))
+        ((output-port? port)
+         (close-output-port port))
+        (else
+         (error 'close-port "not a port" port))))
+
+(define (eof-object) #!eof)
+
 ;;;
 ;;; 6.14. System interface.
 ;;;
Trap