From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pierre Lairez Newsgroups: gmane.lisp.guile.user Subject: Re: EOF as datum Date: Sat, 2 Jul 2016 11:14:58 +0200 Message-ID: <57778612.6000109@gmail.com> References: <57763B70.8010006@gmail.com> <877fd44vb6.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4hUvmo5rxW6mAlvJmm9d2BDodXkSONoBq" X-Trace: ger.gmane.org 1467450985 20450 80.91.229.3 (2 Jul 2016 09:16:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Jul 2016 09:16:25 +0000 (UTC) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jul 02 11:16:20 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 1bJH29-0002rp-Oj for guile-user@m.gmane.org; Sat, 02 Jul 2016 11:16:17 +0200 Original-Received: from localhost ([::1]:37502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJH29-00046F-1z for guile-user@m.gmane.org; Sat, 02 Jul 2016 05:16:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJH0z-0002Pc-EO for guile-user@gnu.org; Sat, 02 Jul 2016 05:15:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJH0w-0004p8-9m for guile-user@gnu.org; Sat, 02 Jul 2016 05:15:05 -0400 Original-Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:36979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJH0v-0004oz-Uq for guile-user@gnu.org; Sat, 02 Jul 2016 05:15:02 -0400 Original-Received: by mail-wm0-x22c.google.com with SMTP id a66so56334533wme.0 for ; Sat, 02 Jul 2016 02:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=MM/7IzqhX4Ik1NvI7cW6FkKAxaHxfVwoP+/PAioxcS4=; b=qNF5SLGo9G6fmyQal5yjrPStepZ4fbXrQgkBEEXGmF/PpZ6nRIDmiVI0Bm8/RkBedt 2oMN0oGszlC1xG+PbUzo7MFgJ0TZbBde+ev6Mzr+/1+9CzLSgsK8w6BwPyU/TkdfO8wp 4KFxXg7pKpRR7MGsPp/Xi+KooRjHR45vnY6sRBewEIfnt95og+t6ElL9eAUKYVrRmJNU JWeQW9POQIfNGOUcuwW6F6pQt49DCfRYb96h0uBIUB4SMEc5sEHHFqPgcHlX0mXevkAU Ph/CaMVKXUOH4K6UqDQWsKbGVPmWoZbrKQzT7ln93rj0V4x1PFI5+YLGv2WRQs5m040v Kmpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=MM/7IzqhX4Ik1NvI7cW6FkKAxaHxfVwoP+/PAioxcS4=; b=ED00ai1lGrsT5fCMUIhbLTvkiYLLHmwmhKGycAz2dkwA0J2cL4PiEHJxgRUmPSwa2M ofiuyRSTto7IqhGtXEIE7qGwZLxRZM0iuq6E2Kx1+hRML3ACAI5BgU2zGRXfN26cY+q1 Ggp9QhN5Lha5tJUFQOY5ezbdDyg6+PVkI4Z+xX+rDngEfSWqpgZW1ztDlEwqrx70u7pI 3LoWPCeL8tSjp5s48cjOO61cNzXFqlz42a8bNw+1FHGgPDLgBNYXboO4IYX6QU6vQbOQ HXaprj2qVTXFtIjdwBNGrXdmLAe5g0bijHvD/y7AWHZNtPW+Mnue4Z+PQbYWAjeWVNJf 7qDA== X-Gm-Message-State: ALyK8tJA57sTdvEM+otx2lbRr49VMFLXmiom5p/TvZGxeu3yoNzgca6lCJ8bhyvaAnC25Q== X-Received: by 10.28.193.78 with SMTP id r75mr2094142wmf.83.1467450901065; Sat, 02 Jul 2016 02:15:01 -0700 (PDT) Original-Received: from [192.168.179.130] (dslb-188-106-178-007.188.106.pools.vodafone-ip.de. [188.106.178.7]) by smtp.gmail.com with ESMTPSA id qg5sm5617927wjc.13.2016.07.02.02.14.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jul 2016 02:15:00 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: <877fd44vb6.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22c X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:12718 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4hUvmo5rxW6mAlvJmm9d2BDodXkSONoBq From: Pierre Lairez To: Mark H Weaver Cc: guile-user@gnu.org Message-ID: <57778612.6000109@gmail.com> Subject: Re: EOF as datum References: <57763B70.8010006@gmail.com> <877fd44vb6.fsf@netris.org> In-Reply-To: <877fd44vb6.fsf@netris.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Mark, Thanks for your answer, and I see your point concerning the non-readability of EOF. And by the way, this point is not so obvious, contrary to what the doc sa= ys: > > Macro: /SCM/ *SCM_EOF_VAL* > > The Scheme end-of-file value. It has no standard written > representation, for obvious reasons. > If Guile would read port using stdio rather that libguile/ports, there would be no problem in reading #, which is just the immediate value 2564. Best, Pierre On 02/07/2016 04:39, Mark H Weaver wrote: > Hi, > > Pierre Lairez writes: > >> I understand why we cannot use (eof-object) in a =E2=80=9Ccase=E2=80=9D= statement. 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 ma= ke >> 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 --4hUvmo5rxW6mAlvJmm9d2BDodXkSONoBq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXd4YSAAoJEBYslBlrVgivDKQH/3n/lCvYB3S8EyXGLbgZPAob EQI1T5VJp31UlcYiZUPQLWgrFddoeIjoYJa3lAf/2EoCdNffceD1hVLgedE94Y4n j35Qnj3HW8ubwc7eYro5G+109tD8zGsWpYrPowGYrbOXxwjx/GNv8HhD7szaPz/C PSf2L2dqooU8OS+fMKwlM7DoS4sdDc/cMizS163QS+LLll0xnWelLurbd7YDYW8W NQrG6DurrKiLg0VWT+mFgbjBtrJW0tBNCe/fRUflSF2PWr5occprvmoHty+ctn+2 wmcsqJLr0FKuv10roxFPPNHm1U7aWnZqKZ6TZRzvvGKbMBCyQYDwXLTxZiJeyG4= =e20I -----END PGP SIGNATURE----- --4hUvmo5rxW6mAlvJmm9d2BDodXkSONoBq--