[6e6002]: impnotes / clos-stream.html Maximize Restore History

Download this file

clos-stream.html    242 lines (241 with data), 48.7 kB

  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
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>29.5. Extensions-1.5. Defining new kinds of Streams</title><link rel="stylesheet" href="impnotes.css" type="text/css" /><link rev="made" href="mailto:clisp-list@sf.net" /><meta name="generator" content="DocBook XSL Stylesheets V1.65.1" /><link rel="home" href="index.html" title="Implementation Notes for GNU CLISP." /><link rel="up" href="p-indep.html" title="Chapter 29. Extensions-1: Platform independent Extensions" /><link rel="previous" href="encoding.html" title="29.4. Extensions-1.4. Encodings" /><link rel="next" href="weak.html" title="29.6. Extensions-1.6. Weak Pointers" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">29.5. Extensions-1.5. Defining new kinds of Streams</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="encoding.html">Prev</a> </td><th width="60%" align="center">Chapter 29. Extensions-1: Platform independent Extensions</th><td width="20%" align="right"> <a accesskey="n" href="weak.html">Next</a></td></tr></table><hr /></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="clos-stream"></a>29.5. Extensions-1.5. Defining new kinds of Streams</h2></div></div><div></div></div><div class="toc"><dl><dt><span class="section"><a href="clos-stream.html#gray">29.5.1. Gray streams</a></span></dt><dt><span class="section"><a href="clos-stream.html#gstream">29.5.2. Generic streams</a></span></dt></dl></div><p>Two mechanisms are supported for creating new streams with
user-defined behavior:
</p><div class="itemizedlist"><ul type="disc"><li>You can create a new subclass of <a href="clos-stream.html#fu-st"><tt class="classname">GRAY:FUNDAMENTAL-STREAM</tt></a> and define
methods for the elementary stream operations on it. These generic
functions all have a name starting with the prefix "stream-".
</li><li>You can create a new subclass of
<tt class="classname">GSTREAM:GENERIC-STREAM-CONTROLLER</tt> and define
methods for the elementary stream operations on it. These generic
functions all have a name starting with the prefix
"generic-stream-". The stream itself is a different object, created
using the function <tt class="function">gstream:make-generic-stream</tt>.
</li></ul></div><p>The <tt class="classname">FUNDAMENTAL-STREAM</tt> API is based on the
<a href="ftp://parcftp.xerox.com/pub/cl/cleanup/mail/stream-definition-by-user.mail" target="_top">STREAM-DEFINITION-BY-USER:GENERIC-FUNCTIONS</a> proposal by David N. Gray and is supported by most <a href="http://www.lisp.org" target="_top"><span><b class="command">Common Lisp</b></span></a>
implementations currently in use.
The <tt class="classname">GSTREAM:GENERIC-STREAM-CONTROLLER</tt>
API is <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a>-specific and is now obsolete.</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="gray"></a>29.5.1. Gray streams</h3></div></div><div></div></div><p>This interface permits the definition of new classes of streams,
and programming their behavior by defining methods for the elementary
stream operations. It is based on the proposal <a href="ftp://parcftp.xerox.com/pub/cl/cleanup/mail/stream-definition-by-user.mail" target="_top">STREAM-DEFINITION-BY-USER:GENERIC-FUNCTIONS</a> of David
N. Gray to X3J13.</p><p>All symbols defined by this interface, starting with the prefix
"fundamental-" or "stream-", are exported from the package
<a href="clos-stream.html#gray" title="29.5.1. Gray streams"><strong class="package"><span class="quote">GRAY</span></strong></a> and re-exported from <a href="imppack.html#ext-pac"><strong class="package"><span class="quote">EXT</span></strong></a>.</p><div class="variablelist"><p class="title"><b>Defined classes</b></p><dl><dt><a id="fu-st"></a><a href="clos-stream.html#fu-st"><tt class="classname">GRAY:FUNDAMENTAL-STREAM</tt></a></dt><dd>This is a superclass of all user-defined streams.
It is a subclass of <a href="http://www.lisp.org/HyperSpec/Body/syscla_stream.html" target="_top"><tt class="classname">STREAM</tt></a> and of <a href="http://www.lisp.org/HyperSpec/Body/cla_standard-object.html" target="_top"><tt class="classname">STANDARD-OBJECT</tt></a>.
Its metaclass is <a href="http://www.lisp.org/HyperSpec/Body/syscla_standard-class.html" target="_top"><tt class="classname">STANDARD-CLASS</tt></a>.</dd><dt><a id="fu-st-in"></a><a href="clos-stream.html#fu-st-in"><tt class="classname">GRAY:FUNDAMENTAL-INPUT-STREAM</tt></a></dt><dd>This is a superclass of all user-defined <a href="http://www.lisp.org/HyperSpec/Body/glo_i.html#input" target="_top">input</a> <a href="http://www.lisp.org/HyperSpec/Body/syscla_stream.html" target="_top"><tt class="classname">STREAM</tt></a>s.
It is a subclass of <a href="clos-stream.html#fu-st"><tt class="classname">GRAY:FUNDAMENTAL-STREAM</tt></a>. The built-in function <a href="http://www.lisp.org/HyperSpec/Body/fun_input-str_put-stream-p.html" target="_top"><tt class="function">INPUT-STREAM-P</tt></a>
returns true on instances of this class. This means that when you
define a new stream class capable of doing input, you have to make it
a subclass of <a href="clos-stream.html#fu-st-in"><tt class="classname">GRAY:FUNDAMENTAL-INPUT-STREAM</tt></a>.</dd><dt><a id="fu-st-out"></a><a href="clos-stream.html#fu-st-out"><tt class="classname">GRAY:FUNDAMENTAL-OUTPUT-STREAM</tt></a></dt><dd>This is a superclass of all user-defined <a href="http://www.lisp.org/HyperSpec/Body/glo_o.html#output" target="_top">output</a> <a href="http://www.lisp.org/HyperSpec/Body/syscla_stream.html" target="_top"><tt class="classname">STREAM</tt></a>s.
It is a subclass of <a href="clos-stream.html#fu-st"><tt class="classname">GRAY:FUNDAMENTAL-STREAM</tt></a>. The built-in function <a href="http://www.lisp.org/HyperSpec/Body/fun_input-str_put-stream-p.html" target="_top"><tt class="function">OUTPUT-STREAM-P</tt></a>
returns true on instances of this class. This means that when you
define a new stream class capable of doing output, you have to make
it a subclass of <a href="clos-stream.html#fu-st-out"><tt class="classname">GRAY:FUNDAMENTAL-OUTPUT-STREAM</tt></a>.</dd><dt><a id="fu-st-char"></a><a href="clos-stream.html#fu-st-char"><tt class="classname">GRAY:FUNDAMENTAL-CHARACTER-STREAM</tt></a></dt><dd>This is a superclass of all user-defined streams
whose <a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a> is <a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><tt class="classname">CHARACTER</tt></a>. It is a subclass of
<a href="clos-stream.html#fu-st"><tt class="classname">GRAY:FUNDAMENTAL-STREAM</tt></a>. It defines a method on <a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a> that returns
<a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><tt class="classname">CHARACTER</tt></a>.</dd><dt><a id="fu-st-bin"></a><a href="clos-stream.html#fu-st-bin"><tt class="classname">GRAY:FUNDAMENTAL-BINARY-STREAM</tt></a></dt><dd>This is a superclass of all user-defined streams
whose <a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a> is a subtype of <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a>. It is a
subclass of <a href="clos-stream.html#fu-st"><tt class="classname">GRAY:FUNDAMENTAL-STREAM</tt></a>. When you define a subclass of <a href="clos-stream.html#fu-st-bin"><tt class="classname">GRAY:FUNDAMENTAL-BINARY-STREAM</tt></a>,
you have to provide a method on <a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a>.
</dd><dt><tt class="classname">GRAY:FUNDAMENTAL-CHARACTER-INPUT-STREAM</tt></dt><dd>This is a convenience class inheriting from both
<a href="clos-stream.html#fu-st-char"><tt class="classname">GRAY:FUNDAMENTAL-CHARACTER-STREAM</tt></a> and <a href="clos-stream.html#fu-st-in"><tt class="classname">GRAY:FUNDAMENTAL-INPUT-STREAM</tt></a>.</dd><dt><tt class="classname">GRAY:FUNDAMENTAL-CHARACTER-OUTPUT-STREAM</tt></dt><dd>This is a convenience class inheriting from both
<a href="clos-stream.html#fu-st-char"><tt class="classname">GRAY:FUNDAMENTAL-CHARACTER-STREAM</tt></a> and <a href="clos-stream.html#fu-st-out"><tt class="classname">GRAY:FUNDAMENTAL-OUTPUT-STREAM</tt></a>.</dd><dt><tt class="classname">GRAY:FUNDAMENTAL-BINARY-INPUT-STREAM</tt></dt><dd>This is a convenience class inheriting from both
<a href="clos-stream.html#fu-st-bin"><tt class="classname">GRAY:FUNDAMENTAL-BINARY-STREAM</tt></a> and <a href="clos-stream.html#fu-st-in"><tt class="classname">GRAY:FUNDAMENTAL-INPUT-STREAM</tt></a>.</dd><dt><tt class="classname">GRAY:FUNDAMENTAL-BINARY-OUTPUT-STREAM</tt></dt><dd>This is a convenience class inheriting from both
<a href="clos-stream.html#fu-st-bin"><tt class="classname">GRAY:FUNDAMENTAL-BINARY-STREAM</tt></a> and <a href="clos-stream.html#fu-st-out"><tt class="classname">GRAY:FUNDAMENTAL-OUTPUT-STREAM</tt></a>.</dd></dl></div><div class="variablelist"><p class="title"><b>General generic functions defined on streams</b></p><dl><dt><tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Returns the stream's element type, normally a
subtype of <a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><tt class="classname">CHARACTER</tt></a> or <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a>.</p><p>The method for <a href="clos-stream.html#fu-st-char"><tt class="classname">GRAY:FUNDAMENTAL-CHARACTER-STREAM</tt></a> returns <a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><tt class="classname">CHARACTER</tt></a>.
</p></dd><dt><tt class="sexp">((<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><tt class="function">SETF</tt></a> <a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a>)
<i class="replaceable"><tt>new-element-type</tt></i> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Changes the stream's element type.</p><p>The default method <a href="http://www.lisp.org/HyperSpec/Body/fun_signal.html" target="_top"><tt class="function">SIGNAL</tt></a>s an <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><tt class="classname">ERROR</tt></a>.</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see <a href="stream-dict.html#stream-eltype" title="21.3.1. Function STREAM-ELEMENT-TYPE">Section 21.3.1, “Function <tt class="function">STREAM-ELEMENT-TYPE</tt></a>).</p></dd><dt><tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_close.html" target="_top"><tt class="function">CLOSE</tt></a>
<i class="replaceable"><tt>stream</tt></i> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><tt class="literal">&amp;KEY</tt></a> <tt class="constant">:ABORT</tt>)</tt></dt><dd><p>Closes the stream and flushes any associated buffers.
</p><p>When you define a primary method on this
function, do not forget to <a href="http://www.lisp.org/HyperSpec/Body/locfun_call-next-method.html" target="_top"><tt class="function">CALL-NEXT-METHOD</tt></a>.
</p></dd><dt><tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_open-stream-p.html" target="_top"><tt class="function">OPEN-STREAM-P</tt></a>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Returns true before the stream has been closed, and
<a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> after the stream has been closed.</p><p>You do not need to add methods to this function.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-POSITION</tt>
<i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>position</tt></i>)</tt></dt><dd><p>Just like <a href="http://www.lisp.org/HyperSpec/Body/fun_file-position.html" target="_top"><tt class="function">FILE-POSITION</tt></a>, but <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>
<i class="replaceable"><tt>position</tt></i> means inquire.</p><p>You must define a method for this function.</p></dd></dl></div><div class="variablelist"><p class="title"><b>generic functions for character input</b></p><dl><dt><a id="st-rc"></a><tt class="sexp">(<a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>If a character was pushed back using <a href="clos-stream.html#st-uc"><tt class="function">GRAY:STREAM-UNREAD-CHAR</tt></a>,
returns and consumes it. Otherwise returns and consumes the next
character from the stream. Returns <tt class="constant">:EOF</tt> if the <a href="http://www.lisp.org/HyperSpec/Body/glo_e.html#end_of_file" target="_top"><tt class="literal">end-of-stream</tt></a> is reached.
</p><p>You must define a method for this function.</p></dd><dt><a id="st-uc"></a><tt class="sexp">(<a href="clos-stream.html#st-uc"><tt class="function">GRAY:STREAM-UNREAD-CHAR</tt></a> <i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>char</tt></i>)</tt></dt><dd><p>Pushes <i class="replaceable"><tt>char</tt></i>, which must be the last character
read from the <i class="replaceable"><tt>stream</tt></i>, back onto the front of the <i class="replaceable"><tt>stream</tt></i>.
</p><p>You must define a method for this function.</p></dd><dt><a id="st-rcnh"></a><tt class="sexp">(<a href="clos-stream.html#st-rcnh"><tt class="function">GRAY:STREAM-READ-CHAR-NO-HANG</tt></a> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Returns a character or <tt class="constant">:EOF</tt>, like <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a>, if
that would return immediately. If <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a>'s value is not available
immediately, returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> instead of waiting.</p><p>
The default method simply calls <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a>; this is sufficient for streams
whose <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> method never blocks.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-PEEK-CHAR</tt> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>If a character was pushed back using <a href="clos-stream.html#st-uc"><tt class="function">GRAY:STREAM-UNREAD-CHAR</tt></a>,
returns it. Otherwise returns the next character from the stream,
avoiding any side effects <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> would do. Returns <tt class="constant">:EOF</tt> if the
<a href="http://www.lisp.org/HyperSpec/Body/glo_e.html#end_of_file" target="_top"><tt class="literal">end-of-stream</tt></a> is reached.</p><p>The default method calls <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> and <a href="clos-stream.html#st-uc"><tt class="function">GRAY:STREAM-UNREAD-CHAR</tt></a>; this is
sufficient for streams whose <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> method has no
side-effects.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-LISTEN</tt> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>If a character was pushed back using <a href="clos-stream.html#st-uc"><tt class="function">GRAY:STREAM-UNREAD-CHAR</tt></a>,
returns it. Otherwise returns the next character from the stream, if
already available. If no character is available immediately, or if
<a href="http://www.lisp.org/HyperSpec/Body/glo_e.html#end_of_file" target="_top"><tt class="literal">end-of-stream</tt></a> is reached, returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>.</p><p>The default method calls <a href="clos-stream.html#st-rcnh"><tt class="function">GRAY:STREAM-READ-CHAR-NO-HANG</tt></a> and <a href="clos-stream.html#st-uc"><tt class="function">GRAY:STREAM-UNREAD-CHAR</tt></a>; this is
sufficient for streams whose <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> method has no
side-effects.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-READ-CHAR-WILL-HANG-P</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> if <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> will return immediately.
Otherwise it returns true.</p><p>The default method calls <a href="clos-stream.html#st-rcnh"><tt class="function">GRAY:STREAM-READ-CHAR-NO-HANG</tt></a> and <a href="clos-stream.html#st-uc"><tt class="function">GRAY:STREAM-UNREAD-CHAR</tt></a>; this is
sufficient for streams whose <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a> method has no side-effects.</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see <a href="stream-dict.html#rcwhp"><tt class="function">EXT:READ-CHAR-WILL-HANG-P</tt></a>).</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-READ-CHAR-SEQUENCE</tt> <i class="replaceable"><tt>stream</tt></i>
<i class="replaceable"><tt>sequence</tt></i> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><tt class="literal">&amp;OPTIONAL</tt></a> [<i class="replaceable"><tt>start</tt></i> [<i class="replaceable"><tt>end</tt></i>]])</tt></dt><dd><p>Fills the subsequence of <i class="replaceable"><tt>sequence</tt></i> specified by
<tt class="constant">:START</tt> and <tt class="constant">:END</tt> with characters consecutively read from <i class="replaceable"><tt>stream</tt></i>.
Returns the index of the first element of <i class="replaceable"><tt>sequence</tt></i> that was not
updated (<a href="http://www.lisp.org/HyperSpec/Body/fun_eqcm_sleq__lteqcm_gteq.html" target="_top"><tt class="function">=</tt></a> <i class="replaceable"><tt>end</tt></i>, or <a href="http://www.lisp.org/HyperSpec/Body/fun_eqcm_sleq__lteqcm_gteq.html" target="_top"><tt class="function">&lt;</tt></a> <i class="replaceable"><tt>end</tt></i> if the stream reached its end).
</p><p><i class="replaceable"><tt>sequence</tt></i> is an <a href="http://www.lisp.org/HyperSpec/Body/syscla_array.html" target="_top"><tt class="classname">ARRAY</tt></a> of <a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><tt class="classname">CHARACTER</tt></a>s, i.e. a <a href="http://www.lisp.org/HyperSpec/Body/syscla_string.html" target="_top"><tt class="classname">STRING</tt></a>.
<i class="replaceable"><tt>start</tt></i> is a nonnegative <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> and defaults to <tt class="literal">0</tt>.
<i class="replaceable"><tt>end</tt></i> is a nonnegative <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> or <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> and defaults to <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>,
which stands for <tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_length.html" target="_top"><tt class="function">LENGTH</tt></a> <i class="replaceable"><tt>sequence</tt></i>)</tt>.
</p><p>The default method repeatedly calls <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a>; this
is always sufficient if speed does not matter.</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see
<a href="stream-dict.html#rd-ch-seq"><tt class="function">EXT:READ-CHAR-SEQUENCE</tt></a>).</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-READ-LINE</tt> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Reads a line of characters, and return two values:
the line (a <a href="http://www.lisp.org/HyperSpec/Body/syscla_string.html" target="_top"><tt class="classname">STRING</tt></a>, without the terminating <span class="keysym">#\Newline</span> character),
and a <a href="http://www.lisp.org/HyperSpec/Body/typ_boolean.html" target="_top"><tt class="classname">BOOLEAN</tt></a> value which is true if the line was terminated by
<a href="http://www.lisp.org/HyperSpec/Body/glo_e.html#end_of_file" target="_top"><tt class="literal">end-of-stream</tt></a> instead of <span class="keysym">#\Newline</span>.</p><p>The default method repeatedly calls <a href="clos-stream.html#st-rc"><tt class="function">GRAY:STREAM-READ-CHAR</tt></a>; this
is always sufficient.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-CLEAR-INPUT</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Clears all pending interactive input from the
<i class="replaceable"><tt>stream</tt></i>, and returns true if some pending input was removed.</p><p>The default method does nothing and returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>; this is
sufficient for non-interactive streams.</p></dd></dl></div><div class="variablelist"><p class="title"><b>generic functions for character output</b></p><dl><dt><a id="st-wc"></a><tt class="sexp">(<a href="clos-stream.html#st-wc"><tt class="function">GRAY:STREAM-WRITE-CHAR</tt></a> <i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>char</tt></i>)</tt></dt><dd><p>Writes <i class="replaceable"><tt>char</tt></i>.
</p><p>You must define a method for this function.</p></dd><dt><a id="st-lc"></a><tt class="sexp">(<a href="clos-stream.html#st-lc"><tt class="function">GRAY:STREAM-LINE-COLUMN</tt></a> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Returns the column number where the next character
would be written (<tt class="literal">0</tt> stands for the first column),
or <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> if that is not meaningful for this stream.
</p><p>You must define a method for this function.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-START-LINE-P</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Returns true if the next character would be
written at the start of a new line.</p><p>The default method calls <a href="clos-stream.html#st-lc"><tt class="function">GRAY:STREAM-LINE-COLUMN</tt></a> and compares its result with
0; this is sufficient for streams whose <a href="clos-stream.html#st-lc"><tt class="function">GRAY:STREAM-LINE-COLUMN</tt></a> never returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>.
</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-WRITE-CHAR-SEQUENCE</tt>
<i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>sequence</tt></i>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><tt class="literal">&amp;OPTIONAL</tt></a> [<i class="replaceable"><tt>start</tt></i> [<i class="replaceable"><tt>end</tt></i>]])</tt></dt><dd><p>Outputs the subsequence of <i class="replaceable"><tt>sequence</tt></i> specified
by <tt class="constant">:START</tt> and <tt class="constant">:END</tt> to <i class="replaceable"><tt>stream</tt></i>.</p><p><i class="replaceable"><tt>sequence</tt></i> is an <a href="http://www.lisp.org/HyperSpec/Body/syscla_array.html" target="_top"><tt class="classname">ARRAY</tt></a> of <a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><tt class="classname">CHARACTER</tt></a>s, i.e. a <a href="http://www.lisp.org/HyperSpec/Body/syscla_string.html" target="_top"><tt class="classname">STRING</tt></a>.
<i class="replaceable"><tt>start</tt></i> is a nonnegative <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> and defaults to 0.
<i class="replaceable"><tt>end</tt></i> is a nonnegative integer or <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> and defaults to <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>,
which stands for <tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_length.html" target="_top"><tt class="function">LENGTH</tt></a> <i class="replaceable"><tt>sequence</tt></i>)</tt>.
</p><p>The default method repeatedly calls <a href="clos-stream.html#st-wc"><tt class="function">GRAY:STREAM-WRITE-CHAR</tt></a>; this
is always sufficient if speed does not matter.
</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension
(see <a href="stream-dict.html#wr-ch-seq"><tt class="function">EXT:WRITE-CHAR-SEQUENCE</tt></a>).</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-WRITE-STRING</tt>
<i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>string</tt></i>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><tt class="literal">&amp;OPTIONAL</tt></a> [<i class="replaceable"><tt>start</tt></i> [<i class="replaceable"><tt>end</tt></i>]])</tt></dt><dd><p>Outputs the subsequence of <i class="replaceable"><tt>string</tt></i> specified by
<tt class="constant">:START</tt> and <tt class="constant">:END</tt> to <i class="replaceable"><tt>stream</tt></i>. Returns <i class="replaceable"><tt>string</tt></i>.</p><p><i class="replaceable"><tt>string</tt></i> is a string. <i class="replaceable"><tt>start</tt></i> is a nonnegative integer
and default to 0. <i class="replaceable"><tt>end</tt></i> is a nonnegative integer or <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> and
defaults to <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>, which stands for <tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_length.html" target="_top"><tt class="function">LENGTH</tt></a>
<i class="replaceable"><tt>string</tt></i>)</tt>.</p><p>The default method calls
<tt class="function">GRAY:STREAM-WRITE-CHAR-SEQUENCE</tt>;
this is always sufficient.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-TERPRI</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Outputs a <span class="keysym">#\Newline</span> character.</p><p>The default method calls <a href="clos-stream.html#st-wc"><tt class="function">GRAY:STREAM-WRITE-CHAR</tt></a>; this is always
sufficient.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-FRESH-LINE</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Possibly outputs a <span class="keysym">#\Newline</span> character, so as to ensure
that the next character would be written at the start of a new line.
Returns true if it did output a <span class="keysym">#\Newline</span> character.</p><p>The default method calls
<tt class="function">GRAY:STREAM-START-LINE-P</tt> and then
<tt class="function">GRAY:STREAM-TERPRI</tt> if necessary; this is always
sufficient.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-FINISH-OUTPUT</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Ensures that any buffered output has reached its
destination, and then returns.</p><p>The default method does nothing.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-FORCE-OUTPUT</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Brings any buffered output on its way towards its
destination, and returns without waiting until it has reached its
destination.</p><p>The default method does nothing.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-CLEAR-OUTPUT</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Attempts to discard any buffered output which has
not yet reached its destination.</p><p>The default method does nothing.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-ADVANCE-TO-COLUMN</tt>
<i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>column</tt></i>)</tt></dt><dd><p>Ensures that the next character will be written at
<i class="replaceable"><tt>column</tt></i> at least.</p><p>The default method outputs an appropriate amount of space
characters; this is sufficient for non-proportional output.</p></dd></dl></div><div class="variablelist"><p class="title"><b>generic functions for binary input</b></p><dl><dt><a id="st-rb"></a><tt class="sexp">(<a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>Returns and consumes the next integer from the
stream. Returns <tt class="constant">:EOF</tt> if the <a href="http://www.lisp.org/HyperSpec/Body/glo_e.html#end_of_file" target="_top"><tt class="literal">end-of-stream</tt></a> is reached.</p><p>You must define a method for this function.</p></dd><dt><a id="st-rbla"></a><tt class="sexp">(<a href="clos-stream.html#st-rbla"><tt class="function">GRAY:STREAM-READ-BYTE-LOOKAHEAD</tt></a> <i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>To be called only if <i class="replaceable"><tt>stream</tt></i>'s
<a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a> is <tt class="type">(<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><tt class="classname">UNSIGNED-BYTE</tt></a> 8)</tt> or <tt class="type">(<a href="http://www.lisp.org/HyperSpec/Body/typ_signed-byte.html" target="_top"><tt class="classname">SIGNED-BYTE</tt></a> 8)</tt>.
Returns <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><tt class="constant">T</tt></a> if <a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a> would return immediately with an
<a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> result. Returns <tt class="constant">:EOF</tt> if the <a href="http://www.lisp.org/HyperSpec/Body/glo_e.html#end_of_file" target="_top"><tt class="literal">end-of-stream</tt></a> is already
known to be reached. If <a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a>'s value is not available
immediately, returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> instead of waiting.</p><p>You must define a method for this function.</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see
<a href="stream-dict.html#rbla"><tt class="function">EXT:READ-BYTE-LOOKAHEAD</tt></a>).</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-READ-BYTE-WILL-HANG-P</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>To be called only if <i class="replaceable"><tt>stream</tt></i>'s
<a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a> is <tt class="type">(<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><tt class="classname">UNSIGNED-BYTE</tt></a> 8)</tt> or <tt class="type">(<a href="http://www.lisp.org/HyperSpec/Body/typ_signed-byte.html" target="_top"><tt class="classname">SIGNED-BYTE</tt></a> 8)</tt>.
Returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> if <a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a> will return immediately.
Otherwise it returns true.</p><p>The default method calls <a href="clos-stream.html#st-rbla"><tt class="function">GRAY:STREAM-READ-BYTE-LOOKAHEAD</tt></a>; this is always sufficient.
</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see <a href="stream-dict.html#rbwhp"><tt class="function">EXT:READ-BYTE-WILL-HANG-P</tt></a>).
</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-READ-BYTE-NO-HANG</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd><p>To be called only if <i class="replaceable"><tt>stream</tt></i>'s
<a href="http://www.lisp.org/HyperSpec/Body/fun_stream-element-type.html" target="_top"><tt class="function">STREAM-ELEMENT-TYPE</tt></a> is <tt class="type">(<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><tt class="classname">UNSIGNED-BYTE</tt></a> 8)</tt> or <tt class="type">(<a href="http://www.lisp.org/HyperSpec/Body/typ_signed-byte.html" target="_top"><tt class="classname">SIGNED-BYTE</tt></a> 8)</tt>.
Returns an <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> or <tt class="constant">:EOF</tt>, like <a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a>, if that would
return immediately. If <a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a>'s value is not available immediately,
returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> instead of waiting.</p><p>The default method calls <a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a> if <a href="clos-stream.html#st-rbla"><tt class="function">GRAY:STREAM-READ-BYTE-LOOKAHEAD</tt></a> returns true;
this is always sufficient.</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see <a href="stream-dict.html#rbnh"><tt class="function">EXT:READ-BYTE-NO-HANG</tt></a>).
</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-READ-BYTE-SEQUENCE</tt>
<i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>sequence</tt></i> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><tt class="literal">&amp;OPTIONAL</tt></a>
[<i class="replaceable"><tt>start</tt></i> [<i class="replaceable"><tt>end</tt></i> [<i class="replaceable"><tt>no-hang</tt></i>]]])</tt></dt><dd><p>Fills the subsequence of <i class="replaceable"><tt>sequence</tt></i> specified by
<tt class="constant">:START</tt> and <tt class="constant">:END</tt> with integers consecutively read from <i class="replaceable"><tt>stream</tt></i>.
Returns the index of the first element of <i class="replaceable"><tt>sequence</tt></i> that was not
updated (<a href="http://www.lisp.org/HyperSpec/Body/fun_eqcm_sleq__lteqcm_gteq.html" target="_top"><tt class="function">=</tt></a> <i class="replaceable"><tt>end</tt></i>, or <a href="http://www.lisp.org/HyperSpec/Body/fun_eqcm_sleq__lteqcm_gteq.html" target="_top"><tt class="function">&lt;</tt></a> <i class="replaceable"><tt>end</tt></i> if the stream reached its end).
</p><p><i class="replaceable"><tt>sequence</tt></i> is an <a href="http://www.lisp.org/HyperSpec/Body/syscla_array.html" target="_top"><tt class="classname">ARRAY</tt></a> of <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a>s.
<i class="replaceable"><tt>start</tt></i> is a nonnegative <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> and defaults to 0.
<i class="replaceable"><tt>end</tt></i> is a nonnegative <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> or <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> and defaults to <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>,
which stands for <tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_length.html" target="_top"><tt class="function">LENGTH</tt></a> <i class="replaceable"><tt>sequence</tt></i>)</tt>.
</p><p>The default method repeatedly calls <a href="clos-stream.html#st-rb"><tt class="function">GRAY:STREAM-READ-BYTE</tt></a>; this
is always sufficient if speed does not matter.</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see
<a href="stream-dict.html#rd-by-seq"><tt class="function">EXT:READ-BYTE-SEQUENCE</tt></a>).</p></dd></dl></div><div class="variablelist"><p class="title"><b>generic functions for binary output</b></p><dl><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-WRITE-BYTE</tt>
<i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>integer</tt></i>)</tt></dt><dd><p>Writes <i class="replaceable"><tt>integer</tt></i>.</p><p>You must define a method for this function.</p></dd><dt><tt class="sexp">(<tt class="function">GRAY:STREAM-WRITE-BYTE-SEQUENCE</tt>
<i class="replaceable"><tt>stream</tt></i> <i class="replaceable"><tt>sequence</tt></i> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><tt class="literal">&amp;OPTIONAL</tt></a>
[<i class="replaceable"><tt>start</tt></i> [<i class="replaceable"><tt>end</tt></i> [<i class="replaceable"><tt>no-hang</tt></i>]]])</tt></dt><dd><p>Outputs the subsequence of <i class="replaceable"><tt>sequence</tt></i> specified
by <tt class="constant">:START</tt> and <tt class="constant">:END</tt> to <i class="replaceable"><tt>stream</tt></i></p><p><i class="replaceable"><tt>sequence</tt></i> is an <a href="http://www.lisp.org/HyperSpec/Body/syscla_array.html" target="_top"><tt class="classname">ARRAY</tt></a> of <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a>s.
<i class="replaceable"><tt>start</tt></i> is a nonnegative <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> and defaults to 0.
<i class="replaceable"><tt>end</tt></i> is a nonnegative <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><tt class="classname">INTEGER</tt></a> or <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> and defaults to <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a>,
which stands for <tt class="sexp">(<a href="http://www.lisp.org/HyperSpec/Body/fun_length.html" target="_top"><tt class="function">LENGTH</tt></a> <i class="replaceable"><tt>sequence</tt></i>)</tt>.
</p><p>The default method repeatedly calls
<tt class="function">GRAY:STREAM-WRITE-BYTE</tt>; this is always
sufficient if speed does not matter.</p><p>This function is a <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a> extension (see
<a href="stream-dict.html#wr-by-seq"><tt class="function">EXT:WRITE-BYTE-SEQUENCE</tt></a>).</p></dd></dl></div></div>
<!--#ifdef GENERIC_STREAMS-->
<div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="gstream"></a>29.5.2. Generic streams</h3></div></div><div></div></div><p>This interface is <a href="http://clisp.cons.org" target="_top"><span><b class="command">CLISP</b></span></a>-specific and now obsolete. Please use
the <a href="clos-stream.html#gray" title="29.5.1. Gray streams">Gray streams</a> interface instead.</p><p>Generic streams are user programmable streams.
The programmer interface:</p><div class="variablelist"><dl><dt><tt class="sexp">(<tt class="function">gstream:make-generic-stream</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt></dt><dd>returns a generic stream.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-controller</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd>returns a private object to which generic stream
methods dispatch. The typical usage is to retrieve the object
originally provided by the user in
<tt class="function">gstream:make-generic-stream</tt>.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-p</tt>
<i class="replaceable"><tt>stream</tt></i>)</tt></dt><dd>determines whether a stream is a generic stream,
returning <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><tt class="constant">T</tt></a> if it is, <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> otherwise.
</dd></dl></div><p>In order to specify the behavior of a generic stream, the user
must define <span><b class="command">CLOS</b></span> methods on the following <span><b class="command">CLOS</b></span> generic
functions. The function
<tt class="function">gstream:generic-stream-<i class="replaceable"><tt>xyz</tt></i></tt>
corresponds to the <a href="http://www.lisp.org" target="_top"><span><b class="command">Common Lisp</b></span></a> function
<tt class="function"><i class="replaceable"><tt>xyz</tt></i></tt>. They all take a
controller and some number of arguments.</p><div class="variablelist"><dl><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-read-char</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt></dt><dd> Returns and consumes the next character, <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> at
end of file. Takes one argument, the controller object.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-peek-char</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt></dt><dd> Returns the next character, <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> at end of file. A
second value indicates whether the side effects associated with
consuming the character were executed: <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><tt class="constant">T</tt></a> means that a full
<a href="http://www.lisp.org/HyperSpec/Body/fun_read-char.html" target="_top"><tt class="function">READ-CHAR</tt></a> was done, <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> means that no side effects were done.
Takes one argument, the controller object.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-read-byte</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt></dt><dd>Returns and consumes the next integer, <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> at end
of file. Takes one argument, the controller object.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-read-char-will-hang-p</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt></dt><dd>This generic function is used to query the stream's
input status. It returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><tt class="constant">NIL</tt></a> if
<tt class="function">gstream:generic-stream-read-char</tt> and
<tt class="function">gstream:generic-stream-peek-char</tt> will certainly
return immediately. Otherwise it returns true.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-write-char</tt>
<i class="replaceable"><tt>controller</tt></i> <i class="replaceable"><tt>char</tt></i>)</tt></dt><dd>The first argument is the controller object.
The second argument is the character to be written.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-write-byte</tt>
<i class="replaceable"><tt>controller</tt></i>
<i class="replaceable"><tt>by</tt></i>)</tt></dt><dd>The first argument is the controller object.
The second argument is the integer to be written.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-write-string</tt>
<i class="replaceable"><tt>controller</tt></i>
<i class="replaceable"><tt>string</tt></i> <i class="replaceable"><tt>start</tt></i> <i class="replaceable"><tt>length</tt></i>)</tt></dt><dd>Writes the subsequence of <i class="replaceable"><tt>string</tt></i> starting from
<i class="replaceable"><tt>start</tt></i> of length <i class="replaceable"><tt>length</tt></i>.
The first argument is the controller object.
</dd><dt><tt class="sexp">(<tt class="function">gstream:generic-stream-clear-input</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt><br /><tt class="sexp">(<tt class="function">gstream:generic-stream-clear-output</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt><br /><tt class="sexp">(<tt class="function">gstream:generic-stream-finish-output</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt><br /><tt class="sexp">(<tt class="function">gstream:generic-stream-force-output</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt><br /><tt class="sexp">(<tt class="function">gstream:generic-stream-close</tt>
<i class="replaceable"><tt>controller</tt></i>)</tt></dt><dd>Take one argument, the controller object.
</dd></dl></div>
<!--#endif-->
</div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="encoding.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="p-indep.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="weak.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">29.4. Extensions-1.4. Encodings </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 29.6. Extensions-1.6. Weak Pointers</td></tr></table></div><div class="custom-footer"><hr width="100%" /><table width="100%"><tr><td align="left"><a href="http://clisp.cons.org"><img src="clisp.png" width="48" height="48" alt="[CLISP home]" /></a></td><td align="center"><a href="http://www.gnu.org"><img src="http://www.gnu.org/graphics/gnubanner.jpg" width="468" height="60" alt="[Come and see what GNU creates for YOU]" /></a></td><td align="right"><a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=1355&amp;amp;type=2" width="125" height="37" alt="[SourceForge]" /></a></td></tr></table></div></body></html>