[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FOLLOW-SYNONYM-STREAM



 From time to time, I find myself doing:

 (LET ((*TERMINAL-IO* *STANDARD-OUTPUT*))
   ...)

in a multi-window system in order to temporarily change my interaction to the
same window as output has been redirected to. On the Lisp Machine (and probably
on many or most other implementations), *STANDARD-OUTPUT* can sometimes (often)
contain a synonym-stream for *TERMINAL-IO* and the result of the operation
above is to send output to a stream which is a (circular) synonym for itself.
The kind of lossage this results in is fairly severe because *DEBUG-IO* is often
a synonym for *TERMINAL-IO* and if that is in turn a synonym for *TERMINAL-IO*,
then the debugger cannot run.

A couple of things would make this problem more tractable:

 SYNONYM-STREAM-P object				[Function]

 This accepts any kind of argument. If the argument is not a synonym
 stream, then NIL is returned. If the argument is a synonym stream,
 then the symbol for which the object is a synonym is returned.

 FOLLOW-SYNONYM-STREAM stream				[Function]

 This accepts a stream and returns the result of following that stream
 through any number of synonym stream indirections (including zero).

While I'm on page 329, I think we should also have the following functions
(or functionalities) which I have needed at other times:

 BROADCAST-STREAM-P object				[Function]
 CONCATENATED-STREAM-P stream				[Function]
 TWO-WAY-STREAM-P					[Function]
 ...

 This accepts any kind of argument. It returns T if the argument is a
 {concatenated/broadcast/two-way/...} stream and NIL if the argument is
 any other kind of stream.

 EXPAND-BROADCAST-STREAM broadcast-stream		[Function]
 EXPAND-CONCATENATED-STREAM concatenated-stream		[Function]
 EXPAND-TWO-WAY-STREAM two-way-stream			[Function]
 ...

 This accepts a {broadcast/concatenated/two-way/...} stream and returns 
 a list of the streams which were used to compose it (in an order 
 compatible with the order of arguments to the creation function).
 Note: Implementations are allowed, but not required, to return the
 same list every time. The result list should not be destructively modified.