Skip to main content

synonym-stream

synonym-stream System Class

Class Precedence List:

synonym-stream, stream, t

Description:

A stream that is an alias for another stream, which is the value of a dynamic variable whose name is the synonym stream symbol of the synonym stream.

Any operations on a synonym stream will be performed on the stream that is then the value of the dynamic variable named by the synonym stream symbol. If the value of the variable should change, or if the variable should be bound, then the stream will operate on the new value of the variable.

See Also:

make-synonym-stream, synonym-stream-symbol

Expanded Reference: synonym-stream

Overview

A synonym-stream is a stream that acts as an alias for whatever stream is the current value of a named dynamic variable. Operations on the synonym stream are forwarded to the target stream.

Type Check

(typep (make-synonym-stream '*standard-input*) 'synonym-stream)
=> T

Dynamic Redirection

If the dynamic variable is rebound, the synonym stream follows the new binding.

(defvar *my-syn-target* (make-string-input-stream "first"))

(let ((syn (make-synonym-stream '*my-syn-target*)))
(let ((r1 (read syn)))
(setq *my-syn-target* (make-string-input-stream "second"))
(list r1 (read syn))))
=> (FIRST SECOND)

Class Hierarchy

(subtypep 'synonym-stream 'stream)
=> T
=> T