aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-04-30 05:04:27 +0000
committerRichard M. Stallman1994-04-30 05:04:27 +0000
commitb664e4837ebc685962169d2c65cc787c6bf334f3 (patch)
tree283f1e7c1faf2cbd9079040415e438a4df703802
parentc567ac01779e2ae8e174ec6ca85a239beeff8f66 (diff)
downloademacs-b664e4837ebc685962169d2c65cc787c6bf334f3.tar.gz
emacs-b664e4837ebc685962169d2c65cc787c6bf334f3.zip
entered into RCS
-rw-r--r--lispref/streams.texi72
1 files changed, 40 insertions, 32 deletions
diff --git a/lispref/streams.texi b/lispref/streams.texi
index 22c9c89ae33..6efa571ff9c 100644
--- a/lispref/streams.texi
+++ b/lispref/streams.texi
@@ -48,7 +48,7 @@ usually produces a similar-looking object. For example, printing the
48symbol @code{foo} produces the text @samp{foo}, and reading that text 48symbol @code{foo} produces the text @samp{foo}, and reading that text
49returns the symbol @code{foo}. Printing a list whose elements are 49returns the symbol @code{foo}. Printing a list whose elements are
50@code{a} and @code{b} produces the text @samp{(a b)}, and reading that 50@code{a} and @code{b} produces the text @samp{(a b)}, and reading that
51text produces a list (but not the same list) with elements are @code{a} 51text produces a list (but not the same list) with elements @code{a}
52and @code{b}. 52and @code{b}.
53 53
54 However, these two operations are not precisely inverses. There are 54 However, these two operations are not precisely inverses. There are
@@ -127,7 +127,7 @@ A symbol as input stream is equivalent to the symbol's function
127definition (if any). 127definition (if any).
128@end table 128@end table
129 129
130 Here is an example of reading from a stream which is a buffer, showing 130 Here is an example of reading from a stream that is a buffer, showing
131where point is located before and after: 131where point is located before and after:
132 132
133@example 133@example
@@ -154,8 +154,8 @@ This is the@point{} contents of foo.
154@end example 154@end example
155 155
156@noindent 156@noindent
157Note that the first read skips a space at the beginning of the buffer. 157Note that the first read skips a space. Reading skips any amount of
158Reading skips any amount of whitespace preceding the significant text. 158whitespace preceding the significant text.
159 159
160 In Emacs 18, reading a symbol discarded the delimiter terminating the 160 In Emacs 18, reading a symbol discarded the delimiter terminating the
161symbol. Thus, point would end up at the beginning of @samp{contents} 161symbol. Thus, point would end up at the beginning of @samp{contents}
@@ -164,7 +164,7 @@ it correctly handles input such as @samp{bar(foo)}, where the delimiter
164that ends one object is needed as the beginning of another object. 164that ends one object is needed as the beginning of another object.
165 165
166 Here is an example of reading from a stream that is a marker, 166 Here is an example of reading from a stream that is a marker,
167initialized to point at the beginning of the buffer shown. The value 167initially positioned at the beginning of the buffer shown. The value
168read is the symbol @code{This}. 168read is the symbol @code{This}.
169 169
170@example 170@example
@@ -185,7 +185,7 @@ This is the contents of foo.
185@end group 185@end group
186@group 186@group
187m 187m
188 @result{} #<marker at 6 in foo> ;; @r{After the first space.} 188 @result{} #<marker at 5 in foo> ;; @r{Before the first space.}
189@end group 189@end group
190@end example 190@end example
191 191
@@ -216,7 +216,7 @@ Lisp expression: @kbd{23 @key{RET}}
216 Finally, here is an example of a stream that is a function, named 216 Finally, here is an example of a stream that is a function, named
217@code{useless-stream}. Before we use the stream, we initialize the 217@code{useless-stream}. Before we use the stream, we initialize the
218variable @code{useless-list} to a list of characters. Then each call to 218variable @code{useless-list} to a list of characters. Then each call to
219the function @code{useless-stream} obtains the next characters in the list 219the function @code{useless-stream} obtains the next character in the list
220or unreads a character by adding it to the front of the list. 220or unreads a character by adding it to the front of the list.
221 221
222@example 222@example
@@ -246,15 +246,15 @@ Now we read using the stream thus constructed:
246 246
247@group 247@group
248useless-list 248useless-list
249 @result{} (41) 249 @result{} (40 41)
250@end group 250@end group
251@end example 251@end example
252 252
253@noindent 253@noindent
254Note that the close parenthesis remains in the list. The reader has 254Note that the open and close parentheses remains in the list. The Lisp
255read it, discovered that it ended the input, and unread it. Another 255reader encountered the open parenthesis, decided that it ended the
256attempt to read from the stream at this point would get an error due to 256input, and unread it. Another attempt to read from the stream at this
257the unmatched close parenthesis. 257point would read @samp{()} and return @code{nil}.
258 258
259@defun get-file-char 259@defun get-file-char
260This function is used internally as an input stream to read from the 260This function is used internally as an input stream to read from the
@@ -274,7 +274,7 @@ defaults to the value of @code{standard-input}.
274 274
275@kindex end-of-file 275@kindex end-of-file
276 An @code{end-of-file} error is signaled if reading encounters an 276 An @code{end-of-file} error is signaled if reading encounters an
277unterminated list, vector or string. 277unterminated list, vector, or string.
278 278
279@defun read &optional stream 279@defun read &optional stream
280This function reads one textual Lisp expression from @var{stream}, 280This function reads one textual Lisp expression from @var{stream},
@@ -288,10 +288,10 @@ This function reads the first textual Lisp expression from the text in
288and whose @sc{cdr} is an integer giving the position of the next 288and whose @sc{cdr} is an integer giving the position of the next
289remaining character in the string (i.e., the first one not read). 289remaining character in the string (i.e., the first one not read).
290 290
291If @var{start} is supplied, then reading begins at index @var{start} in the 291If @var{start} is supplied, then reading begins at index @var{start} in
292string (where the first character is at index 0). If @var{end} is also 292the string (where the first character is at index 0). If @var{end} is
293supplied, then reading stops at that index as if the rest of the string 293also supplied, then reading stops just before that index, as if the rest
294were not there. 294of the string were not there.
295 295
296For example: 296For example:
297 297
@@ -313,7 +313,7 @@ For example:
313@group 313@group
314;; @r{Read starting at the second character.} 314;; @r{Read starting at the second character.}
315(read-from-string "(list 112)" 1) 315(read-from-string "(list 112)" 1)
316 @result{} (list . 6) 316 @result{} (list . 5)
317@end group 317@end group
318@group 318@group
319;; @r{Read starting at the seventh character,} 319;; @r{Read starting at the seventh character,}
@@ -347,7 +347,7 @@ Point advances as characters are inserted.
347@item @var{marker} 347@item @var{marker}
348@cindex marker output stream 348@cindex marker output stream
349The output characters are inserted into the buffer that @var{marker} 349The output characters are inserted into the buffer that @var{marker}
350points into, at the marker position. The position advances as 350points into, at the marker position. The marker position advances as
351characters are inserted. The value of point in the buffer has no effect 351characters are inserted. The value of point in the buffer has no effect
352on printing when the stream is a marker. 352on printing when the stream is a marker.
353 353
@@ -373,6 +373,10 @@ A symbol as output stream is equivalent to the symbol's function
373definition (if any). 373definition (if any).
374@end table 374@end table
375 375
376 Many of the valid output streams are also valid as input streams. The
377difference between input and output streams is therefore mostly one of
378how you use a Lisp object, not a distinction of types of object.
379
376 Here is an example of a buffer used as an output stream. Point is 380 Here is an example of a buffer used as an output stream. Point is
377initially located as shown immediately before the @samp{h} in 381initially located as shown immediately before the @samp{h} in
378@samp{the}. At the end, point is located directly before that same 382@samp{the}. At the end, point is located directly before that same
@@ -399,11 +403,11 @@ This is t
399@end example 403@end example
400 404
401 Now we show a use of a marker as an output stream. Initially, the 405 Now we show a use of a marker as an output stream. Initially, the
402marker points in buffer @code{foo}, between the @samp{t} and the 406marker is in buffer @code{foo}, between the @samp{t} and the @samp{h} in
403@samp{h} in the word @samp{the}. At the end, the marker has been 407the word @samp{the}. At the end, the marker has advanced over the
404advanced over the inserted text so that it still points before the same 408inserted text so that it remains positioned before the same @samp{h}.
405@samp{h}. Note that the location of point, shown in the usual fashion, 409Note that the location of point, shown in the usual fashion, has no
406has no effect. 410effect.
407 411
408@example 412@example
409@group 413@group
@@ -490,6 +494,10 @@ Now we can put the output in the proper order by reversing the list:
490@end group 494@end group
491@end example 495@end example
492 496
497@noindent
498Calling @code{concat} converts the list to a string so you can see its
499contents more clearly.
500
493@node Output Functions 501@node Output Functions
494@section Output Functions 502@section Output Functions
495 503
@@ -503,9 +511,9 @@ Now we can put the output in the proper order by reversing the list:
503output when necessary so that it can be read properly. The quoting 511output when necessary so that it can be read properly. The quoting
504characters used are @samp{"} and @samp{\}; they distinguish strings from 512characters used are @samp{"} and @samp{\}; they distinguish strings from
505symbols, and prevent punctuation characters in strings and symbols from 513symbols, and prevent punctuation characters in strings and symbols from
506being taken as delimiters. @xref{Printed Representation}, for full 514being taken as delimiters when reading. @xref{Printed Representation},
507details. You specify quoting or no quoting by the choice of printing 515for full details. You specify quoting or no quoting by the choice of
508function. 516printing function.
509 517
510 If the text is to be read back into Lisp, then it is best to print 518 If the text is to be read back into Lisp, then it is best to print
511with quoting characters to avoid ambiguity. Likewise, if the purpose is 519with quoting characters to avoid ambiguity. Likewise, if the purpose is
@@ -558,9 +566,9 @@ characters are used. @code{print} returns @var{object}. For example:
558 566
559@defun prin1 object &optional stream 567@defun prin1 object &optional stream
560This function outputs the printed representation of @var{object} to 568This function outputs the printed representation of @var{object} to
561@var{stream}. It does not print any spaces or newlines to separate 569@var{stream}. It does not print newlines to separate output as
562output as @code{print} does, but it does use quoting characters just 570@code{print} does, but it does use quoting characters just like
563like @code{print}. It returns @var{object}. 571@code{print}. It returns @var{object}.
564 572
565@example 573@example
566@group 574@group
@@ -686,7 +694,7 @@ In the second expression, the local binding of
686@cindex printing limits 694@cindex printing limits
687The value of this variable is the maximum number of elements of a list 695The value of this variable is the maximum number of elements of a list
688that will be printed. If a list being printed has more than this many 696that will be printed. If a list being printed has more than this many
689elements, then it is abbreviated with an ellipsis. 697elements, it is abbreviated with an ellipsis.
690 698
691If the value is @code{nil} (the default), then there is no limit. 699If the value is @code{nil} (the default), then there is no limit.
692 700
@@ -705,7 +713,7 @@ If the value is @code{nil} (the default), then there is no limit.
705 713
706@defvar print-level 714@defvar print-level
707The value of this variable is the maximum depth of nesting of 715The value of this variable is the maximum depth of nesting of
708parentheses that will be printed. Any list or vector at a depth 716parentheses and brackets when printed. Any list or vector at a depth
709exceeding this limit is abbreviated with an ellipsis. A value of 717exceeding this limit is abbreviated with an ellipsis. A value of
710@code{nil} (which is the default) means no limit. 718@code{nil} (which is the default) means no limit.
711 719