<div dir="ltr">I'm doing some gray streams programming and came across a weird little corner case. In ccl, when I call peek-char with just the gray stream (it is a string-based stream), ccl hangs. Other lisps (clisp, sbcl) throw an exception, complaining that the peek-type is not an expected type (one of the types defined for peek-type - null, t, character)<div>
<br></div><div>However, CLHS says:</div><div><br></div><div>If peek-type is not supplied or nil, peek-char returns the next character to be read from input-stream<br></div><div><br></div><div><a href="http://clhs.lisp.se/Body/f_peek_c.htm">http://clhs.lisp.se/Body/f_peek_c.htm</a><br>
</div><div><br></div><div>So ... wouldn't one expect that (peek-char stream) would behave like (peek-char nil stream)?<br></div><div><br></div><div>And as a reminder here is what peek-char looks like:</div><div><br></div>
<div>peek-char &optional peek-type input-stream eof-error-p eof-value recursive-p => char<br></div><div><br></div><div>So there are two issues here. First is how peek-char should behave when a stream is the first argument. Second is that ccl should probably not hang in this situation.</div>
<div><br></div><div>CCL looks to be doing the right thing by using standard input as the default stream, which it does because it doesn't think a value has been supplied for the stream argument. It only inspects the first argument after reading from the stream, which hangs because there is nothing in standard input (in my case).</div>
<div><br></div><div>It should probably inspect the first argument first, and if it is an input stream either reject it like the other lisps (wrong, imo) or use it as the input stream if it is a input-stream-p (and make necessary adjustments to the other arguments).</div>
<div><br></div><div>Thoughts?</div><div><br></div><div>Thanks,</div><div>Erik.</div><div><br></div><div><br></div></div>