Debian Codegraph @

doc/read-delimited.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <HTML>
3 <HEAD>
4 <TITLE>Function READ-DELIMITED</TITLE>
5 <LINK REL="stylesheet" HREF="style.css" type="text/css">
6 </HEAD>
7 <BODY>
8
9 <p><p><i>Function</i> <b>READ-DELIMITED</b></p>
10
11 <p><p><b>Syntax:</b></p>
12
13 <p><p><b>read-delimited</b> <i>sequence stream <tt>&key </tt> start end delimiter test key</i> => <i>position, delimited-p</i></p>
14
15 <p><p><b>Arguments and Values:</b></p>
16
17 <p><p><i>sequence</i>---a <i>sequence</i>.</p>
18
19 <p><i>stream</i>---an <i>input stream</i>.</p>
20 <p><i>start, end</i>---<i>bounding index designators</i> of
21 <i>sequence</i>. The defaults for <i>start</i> and <i>end</i> are 0
22 and <b>nil</b>, respectively.
23
24 <p><i>delimiter</i>---a <i>character</i>. It defaults to #\newline.</p>
25 <p><i>test</i>---a <i>designator</i> for a <i>function</i> of two
26 <i>arguments</i> that returns a <i>generalized boolean</i>.</p>
27
28 <p><i>key</i>---a <i>designator</i> for a <i>function</i> of one
29 argument, or <b>nil</b>.</p>
30 <p><i>position</i>---an <i>integer</i> greater than or equal to zero,
31 and less than or equal to the <i>length</i> of the sequence.</p>
32
33 <p><i>delimited-p</i>---the result of the last invokation of <i>test</i></p>
34
35 <p><p><b>Description:</b></p>
36
37 <p><p>Destructively modifies <i>sequence</i> by replacing
38 <i>elements</i> of <i>sequence</i> <i>bounded</i> by <i>start</i> and
39 <i>end</i> with <i>elements</i> read from <i>stream</i>.</p>
40
41 <p><p><i>Test</i> is called with the actual read character, converted
42 by applying <i>key</i> to it, as the first and <i>delimiter</i> as the
43 second argument.</p>
44
45 <p><p>If a character is read for which (funcall <i>test</i> (funcall
46 <i>key</i> <b>char</b>) <i>delimiter</i>) is non-nil,
47 <b>read-delimited</b> terminates the copying even before reaching
48 <i>end of file</i> or the <i>end</i> of the <i>bounding
49 designator</i>.</p>
50
51 <p><p><b>read-delimited</b> returns the index of the first
52 <i>element</i> of <i>sequence</i> that was not updated as the first
53 and the result of the last invokation of <i>test</i> as the second
54 value.</p>
55
56 <p><p><i>Sequence</i> is destructively modified by copying successive
57 <i>elements</i> into it from <i>stream</i>. If the <i>end of file</i>
58 for <i>stream</i> is reached before copying all <i>elements</i> of the
59 subsequence, then the extra <i>elements</i> near the end of
60 <i>sequence</i> are not updated.</p>
61
62 <p><b>Exceptional situations:</b>
63
64 <p>If <i>start</i> and/or <i>end</i> are out of bounds, or if
65 <i>start</i> &gt; <i>end</i>, then a
66 <b>read-delimited-bounds-error</b> error is signalled. This error is
67 passed the values of <i>start</i>, <i>end</i>, and <i>sequence</i>,
68 which can be read with <b>read-delimited-bounds-error-start</b>,
69 <b>read-delimited-bounds-error-end</b>, and
70 <b>read-delimited-bounds-error-sequence</b>,
71 respectively.
72
73 <p><p><b>Implementation notes:</b></p>
74
75 <p>This is one of the more complex utilities, and the amount of
76 argument checking needed to do it properly is daunting. An amazing 76%
77 of the code is spent on making sure that the bounds are valid and in
78 order, and on what to do if they aren't. Once you remove all that, the
79 actual function which does all the work is quite simple, and unlikely
80 to contain bugs.</p>
81
82 <p>The design of this function makes it a little annoying to use, but
83 it is more efficient. If you need something more high-level, this
84 could be built on top of <b>read-delimited</b> fairly easily.</p>
85
86 <p class="footer"><hr><a href="index.html">Manual Index</a></p>
87
88 </body></html>