Skip to content

Commit 5cb072e

Browse files
committed
crook
1 parent 8b6393c commit 5cb072e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

iniquity-plus/interp-io.rkt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
;; Interpret p with given string as input,
66
;; return value and collected output as string
77
(define (interp/io p input)
8-
(parameterize ((current-output-port (open-output-string))
9-
(current-input-port (open-input-string input)))
10-
(cons (interp p)
11-
(get-output-string (current-output-port)))))
8+
(define result (box #f))
9+
(define output
10+
(with-input-from-string input
11+
(λ ()
12+
(with-output-to-string
13+
(λ ()
14+
(set-box! result (interp p)))))))
15+
(cons (unbox result) output))
1216

knock-plus/interp-io.rkt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
;; Interpret p with given string as input,
66
;; return value and collected output as string
77
(define (interp/io p input)
8-
(parameterize ((current-output-port (open-output-string))
9-
(current-input-port (open-input-string input)))
10-
(cons (interp p)
11-
(get-output-string (current-output-port)))))
8+
(define result (box #f))
9+
(define output
10+
(with-input-from-string input
11+
(λ ()
12+
(with-output-to-string
13+
(λ ()
14+
(set-box! result (interp p)))))))
15+
(cons (unbox result) output))
1216

0 commit comments

Comments
 (0)