From 85fd220700d151766c767f0193ea4d10bb1056ae Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 28 May 2018 17:35:07 -0700 Subject: [PATCH] Implement call-with-port for R7RS. --- src/runtime/runtime.pkg | 1 + src/runtime/textual-port.scm | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index a00a914c2..faac808ce 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -2675,6 +2675,7 @@ USA. with-output-to-port with-trace-output-port) (export () + call-with-port close-input-port close-output-port close-port diff --git a/src/runtime/textual-port.scm b/src/runtime/textual-port.scm index 7843e0bb8..affb59e78 100644 --- a/src/runtime/textual-port.scm +++ b/src/runtime/textual-port.scm @@ -653,6 +653,11 @@ USA. (cond ((binary-port? port) (binary-port-metadata port)) ((textual-port? port) (textual-port-metadata port)) (else (error:not-a port? port 'port-metadata)))) + +(define (call-with-port port procedure) + (let ((value (procedure port))) + (close-port port) + value)) ;;;; Port modes -- 2.25.1