From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: EOF as datum Date: Fri, 01 Jul 2016 22:39:57 -0400 Message-ID: <877fd44vb6.fsf@netris.org> References: <57763B70.8010006@gmail.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 1467427276 8649 80.91.229.3 (2 Jul 2016 02:41:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Jul 2016 02:41:16 +0000 (UTC) Cc: guile-user@gnu.org To: Pierre Lairez Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jul 02 04:41:07 2016 Return-path: Envelope-to: guile-user@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 1bJArh-0007Rh-Cc for guile-user@m.gmane.org; Sat, 02 Jul 2016 04:41:05 +0200 Original-Received: from localhost ([::1]:36693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJArg-0003dy-F2 for guile-user@m.gmane.org; Fri, 01 Jul 2016 22:41:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJAr7-0003cZ-Pr for guile-user@gnu.org; Fri, 01 Jul 2016 22:40:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJAqz-0004M2-9Q for guile-user@gnu.org; Fri, 01 Jul 2016 22:40:28 -0400 Original-Received: from world.peace.net ([50.252.239.5]:60231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJAqz-0004HM-64 for guile-user@gnu.org; Fri, 01 Jul 2016 22:40:21 -0400 Original-Received: from pool-71-174-37-60.bstnma.east.verizon.net ([71.174.37.60] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bJAq1-0000AO-0j; Fri, 01 Jul 2016 22:39:21 -0400 In-Reply-To: <57763B70.8010006@gmail.com> (Pierre Lairez's message of "Fri, 1 Jul 2016 11:44:16 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 50.252.239.5 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:12717 Archived-At: Hi, Pierre Lairez writes: > I understand why we cannot use (eof-object) in a =E2=80=9Ccase=E2=80=9D s= tatement. For > example, this will not run as it is meant: > (case (get-char port) > (((eof-object)) ...) > (else ...)) > > Is is possible to define something like #eof that will be datum and make > the following work as expected? > (case (get-char port) > ((#eof) ...) > (else ...)) We cannot make a 'read'able datum that is an eof object, because of the API of 'read'. When 'read' returns an eof object, that means that the end of file has been reached, and that's how existing callers of 'read' will interpret such a result. I would suggest using (ice-9 match) instead, e.g.: (match (get-char port) ((? eof-object?) 'eof) ((or #\a #\b) 'a-or-b) (#\c 'c) (char 'other-character)) See section 7.7 (Pattern Matching) in the Guile manual. Does that work for you? Regards, Mark