Next: , Previous: Port Properties, Up: Files and Ports


4.6.3 Port Redirection

— Function: current-error-port

Returns the current port to which diagnostic output is directed.

— Function: with-error-to-file string thunk

thunk must be a procedure of no arguments, and string must be a string naming a file. The file is opened for output, an output port connected to it is made the default value returned by current-error-port, and the thunk is called with no arguments. When the thunk returns, the port is closed and the previous default is restored. With-error-to-file returns the value yielded by thunk.

— Function: with-input-from-port port thunk
— Function: with-output-to-port port thunk
— Function: with-error-to-port port thunk

These routines differ from with-input-from-file, with-output-to-file, and with-error-to-file in that the first argument is a port, rather than a string naming a file.

— Function: call-with-outputs thunk proc

Calls the thunk procedure while the current-output-port and current-error-port are directed to string-ports. If thunk returns, the proc procedure is called with the output-string, the error-string, and the value returned by thunk. If thunk does not return a value (perhaps because of error), proc is called with just the output-string and the error-string as arguments.