Added with-output-to-port:

> (let-values ([(p e) (open-string-output-port)])
    (with-output-to-port p (lambda () (printf "Hello\n")))
    (e))
"Hello\n"
This commit is contained in:
Abdulaziz Ghuloum 2008-04-29 00:20:29 -04:00
parent d8cd4f0acf
commit f69e82e6c5
3 changed files with 16 additions and 2 deletions

View File

@ -45,6 +45,7 @@
open-bytevector-output-port
call-with-bytevector-output-port
open-string-output-port with-output-to-string
with-output-to-port
call-with-string-output-port
open-output-string get-output-string
standard-output-port standard-error-port
@ -112,6 +113,7 @@
current-output-port current-error-port
open-file-output-port open-output-file
call-with-output-file with-output-to-file
with-output-to-port
console-output-port
console-input-port
console-error-port
@ -469,7 +471,18 @@
(parameterize ([*the-output-port* p])
(proc))
(extract)))
(define (with-output-to-port p proc)
(define who 'with-output-to-port)
(unless (procedure? proc)
(die who "not a procedure" proc))
(unless (output-port? p)
(die who "not an output port" p))
(unless (textual-port? p)
(die who "not a textual port" p))
(parameterize ([*the-output-port* p])
(proc)))
(define-struct output-string-cookie (strings))

View File

@ -1 +1 @@
1455
1456

View File

@ -1186,6 +1186,7 @@
[read-char i r is se]
[with-input-from-file i r is se]
[with-output-to-file i r is se]
[with-output-to-port i]
[write i r is se]
[write-char i r is se]
[call-with-input-file i r is se]