(with-input-from-string string thunk)
Thunk must be a procedure of no arguments. with-input-from-string creates a new input port that reads from string, makes that port the current input port, and calls thunk. When thunk returns, with-input-from-string restores the previous current input port and returns the result yielded by thunk.
Note: this procedure is equivalent to:
(with-input-from-port (string->input-port string) thunk)
A symbolic expression or the EOF object.
(define (with-input-from-string string thunk) (let ((oldport (current-input-port)) (newport (open-input-string string))) (dynamic-wind (lambda () (set-current-input-port! newport)) thunk (lambda () (set-current-input-port! oldport)))))
> (with-input-from-string "(a b c) (d e f)" read) (a b c) >