5.3 Debugging under multitasking

5.3.2 Binding stream values

The standard streams in Common Lisp are*standard-input**standard-output*,*debug-io*,*error-io*,*query-io*,*terminal-io*, and*trace-output*; these variables are Lisp symbols whose values are streams that receive input and output. The evaluation of these symbols takes place in the process where the input or output occurs. Thus, these symbols can be dynamically bound to different values in different processes. You can redirect the input or output for any stream that is a synonym stream for*terminal-io* by binding that variable in the same process that generates the input or output.

To prevent I/O from going to the wrong stream, you can use a top-level function to bind some of the standard streams to particular values for a process. Then, if you use the Common Lisp special formsetq to change the value of a stream, only one process is affected. If you do not explicitly bind a standard stream in a process, the stream retains its global value; any change made to the symbol in the process is seen by all processes that do not use their own bindings for the stream.

Note: Do not bind the variable*terminal-io* to a string stream. Trying to read past the end-of-file marker for such streams could cause Lisp to exit without a message.


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker