From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "David A. Wheeler" Newsgroups: gmane.lisp.guile.bugs Subject: bug#12216: peek-char incorrectly *CONSUMES* eof Date: Sat, 09 Mar 2013 12:11:12 -0500 (EST) Message-ID: References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> Reply-To: dwheeler@dwheeler.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1362849162 9529 80.91.229.3 (9 Mar 2013 17:12:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Mar 2013 17:12:42 +0000 (UTC) Cc: almkglor , 12216 <12216@debbugs.gnu.org> To: "mandyke" Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sat Mar 09 18:13:02 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UENKQ-0007IJ-FG for guile-bugs@m.gmane.org; Sat, 09 Mar 2013 18:13:02 +0100 Original-Received: from localhost ([::1]:35269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UENK4-0005oS-Ey for guile-bugs@m.gmane.org; Sat, 09 Mar 2013 12:12:40 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UENJt-0005iY-O2 for bug-guile@gnu.org; Sat, 09 Mar 2013 12:12:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UENJi-0007uS-O6 for bug-guile@gnu.org; Sat, 09 Mar 2013 12:12:29 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UENJi-0007u8-LJ for bug-guile@gnu.org; Sat, 09 Mar 2013 12:12:18 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UENKQ-0007N8-8I for bug-guile@gnu.org; Sat, 09 Mar 2013 12:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "David A. Wheeler" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 09 Mar 2013 17:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12216 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 12216-submit@debbugs.gnu.org id=B12216.136284912228268 (code B ref 12216); Sat, 09 Mar 2013 17:13:02 +0000 Original-Received: (at 12216) by debbugs.gnu.org; 9 Mar 2013 17:12:02 +0000 Original-Received: from localhost ([127.0.0.1]:42058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UENJR-0007La-1x for submit@debbugs.gnu.org; Sat, 09 Mar 2013 12:12:02 -0500 Original-Received: from aibo.runbox.com ([91.220.196.211]:52170) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UENJO-0007LT-Rg for 12216@debbugs.gnu.org; Sat, 09 Mar 2013 12:11:59 -0500 Original-Received: from [10.9.9.135] (helo=taishi.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UENIe-0003r3-JE; Sat, 09 Mar 2013 18:11:12 +0100 Original-Received: from mail by taishi.runbox.com with local (Exim 4.69) id 1UENIe-0007sf-IU; Sat, 09 Mar 2013 18:11:12 +0100 Content-Disposition: inline Original-Received: from [108.45.113.66] by secure.runbox.com with http (uid:258406) (RMM 4.0); Sat, 09 Mar 2013 17:11:12 GMT X-Mailer: RMM5 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6909 Archived-At: Daniel Hartwig: > Indeed. There is a distinction between the end-of-file _object_ > (Scheme) and end-of-transmission _character_ (ASCII ^D). The two are > not equivalent, ... Sure. > and when read-char and peek-char return the former > value it is only to signal a _current_ lack of characters and should > not be considered part of the character stream read from the port. If I understand you correctly, that sounds more like "char-ready?". In any case, I believe guile fails to meet the semantics of R5RS, and I believe other versions of the Scheme spec, in this area. R5RS says: > (peek-char) procedure > (peek-char port) procedure > Returns the next character available from the input port, > without updating the port to point to the following character. > If no more characters are available, an end of =0Cle > object is returned. Port may be omitted, in which case it > defaults to the value returned by current-input-port. > Note: The value returned by a call to peek-char is the same as > the value that would have been returned by a call to read-char > with the same port. The only diff=0Berence is that the very next call > to read-char or peek-char on that port will return the value > returned by the preceding call to peek-char. In particular, a > call to peek-char on an interactive port will hang waiting for > input whenever a call to read-char would have hung. Note that the spec says that the very next call "to read-char or peek-char on that port will return the value returned by the preceding call to peek-char." It does not say the same *CHARACTER*, it says the same *VALUE*, and the eof object is a possible value from peek-char and read-char. I'd be okay if, after a read-char of EOF, it could return something else as some sort of extension. But (peek-char) (peek-char) (peek-char) should return the same values 3 times, no matter what... even if it's EOF. --- David A. Wheeler