Page 354 Table of Contents Index Page 356
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E



APPENDIX D. ENCAPSULATING STREAMS

All encapsulating streams must handle the :stream initarg, which is used to specify the stream
to be encapsulated.

=> standard-encapsulating-stream [Class]
This class provides a standard implementation of an encapsulating stream.

D.1.1 Encapsulating Stream Protocol

The standard-encapsulating-stream class must provide "trampoline" methods for all stream
protocol operations. These "trampolines" will simply call the same generic function on the
encapsulated stream. In particular, all of the generic functions in the following protocols must
have trampolines. The following generic function must also be implemented for all encapsulating stream classes.
=> encapsulating-stream-stream encapsulating-stream [Generic Function]
Returns the stream encapsulated by the encapsulating stream encapsulating-stream.

D.1.2 The "Delegation Problem"

The suggested implementation of encapsulating streams has a potential problem that we label
the "delegation" or "multiple self" problem. Here is an example of the problem.

Suppose we implement accepting-values by using an encapsulating stream class called accepting-
values-stream
that will be used to close over an ordinary extended input and output stream.


Page 354 Table of Contents Index Page 356
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E