[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12216: peek-char incorrectly *CONSUMES* eof

From: Andy Wingo
Subject: bug#12216: peek-char incorrectly *CONSUMES* eof
Date: Tue, 05 Mar 2013 17:53:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)


On Fri 17 Aug 2012 03:53, "David A. Wheeler" <address@hidden> writes:

> Guile's peek-char has a bug; it incorrectly *consumes* eof instead of
> just reporting it.

I'm not sure there is a sane way to deal with this.  Guile's ports are
fundamentally binary, underneath.  The backing store is a byte buffer
that is decoded and encoded to Scheme characters at need, along with
vtable to fill and flush that buffer.  You can do strange things like
unread characters, switch the encoding, and read them back out in a
different encoding.  There is no way to represent EOF in that buffer.

I have the feeling that for interactive use, if you expect to read a EOF
from a port and then continue, you have to not use peek-char.  You need
to handle your own lookahead buffer.  I know it's not a great answer,
but I can't think of anything else that makes sense.

What do you think?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]