unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: John Cowan <cowan@ccil.org>
To: Zefram <zefram@fysh.org>
Cc: 38398@debbugs.gnu.org
Subject: bug#38398: non-obvious SCM_EOF_VAL rationale
Date: Wed, 27 Nov 2019 03:55:47 -0500	[thread overview]
Message-ID: <CAD2gp_T8h2X5JK9zS1aOnnZO7rMGnsvuPrfS9a3KoHO3A_QrOw@mail.gmail.com> (raw)
In-Reply-To: <20191127074436.e6gev22lgi2yqpkg@fysh.org>

[-- Attachment #1: Type: text/plain, Size: 2452 bytes --]

On Wed, Nov 27, 2019 at 2:45 AM Zefram via Bug reports for GUILE, GNU's
Ubiquitous Extension Language <bug-guile@gnu.org> wrote:


> It's fairly obvious
> that it's a value that can't be returned by read-char, and therefore is
> not itself a character, but that's quite a different matter.


On the contrary:  the EOF object is not a character, but it *can* be
returned by read-char .  Indeed it *is* returned by read-char just in case
read-char is called after the last character of its input port has been
read.  This makes it possible to distinguish between two cases: read-char
returns a character if there are any in the input port, and the EOF object
if there are none.

By the same token, read can return either a datum value or an EOF object.
It returns a datum value if the remaining characters in its input port
constitute at least one datum (what R6RS calls an "external
representation") or the EOF object if no characters are available, and
raises an exception if the available characters do not constitute a datum.
An input port containing just "(", for example, will not return an EOF
object; it will raise an exception.


> The lack of
> s-expression representation actually comes from the entirely unobvious,
> and undocumented in Guile, use of the EOF value with the read function.
>

It's true that section 6.18.2 of the Guile 2.2.x manual is rather terse and
does not document this behavior.  However, section 4.1 says that Guile is
fully compliant with R5RS.  This means that it incorporates by reference
the R5RS specification, and in particular section 6.6.2, which restates at
greater length the rules I have given above.  The definition of read in
R6RS defers to the definition of get-datum (both are in library section
8.2.9), which is yet another restatement of the same rules.


> This poor design precludes RnRS specifying read syntax for any
> EOF object.


Why do you believe it to be a poor design?  It seems quite appropriate to
me for the EOF object not to be a datum value, for the same reason that it
should not be a character.  You nowhere state what purpose such a read
syntax would serve.  Do you wish to be able to use read to input a list of
EOF objects, for instance?  What would you do with them?



John Cowan          http://vrici.lojban.org/~cowan        cowan@ccil.org
Pour moi, les villes du Silmarillion ont plus de realite que Babylone.
                --Christopher Tolkien, as interviewed by Le Monde

[-- Attachment #2: Type: text/html, Size: 3394 bytes --]

  reply	other threads:[~2019-11-27  8:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  7:44 bug#38398: non-obvious SCM_EOF_VAL rationale Zefram via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2019-11-27  8:55 ` John Cowan [this message]
2019-11-27 12:05   ` Zefram via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2019-11-27 12:34     ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAD2gp_T8h2X5JK9zS1aOnnZO7rMGnsvuPrfS9a3KoHO3A_QrOw@mail.gmail.com \
    --to=cowan@ccil.org \
    --cc=38398@debbugs.gnu.org \
    --cc=zefram@fysh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).