unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Marko Rauhamaa <marko@pacujo.net>
To: guile-user@gnu.org
Subject: Re: Nonblocking get-bytevector-n bug?
Date: Mon, 07 Dec 2015 13:15:01 +0200	[thread overview]
Message-ID: <87610abjd6.fsf@elektro.pacujo.net> (raw)
In-Reply-To: <87h9jubli1.fsf@elektro.pacujo.net> (Marko Rauhamaa's message of "Mon, 07 Dec 2015 12:28:54 +0200")

Marko Rauhamaa <marko@pacujo.net>:

> ludo@gnu.org (Ludovic Courtès):
>> That’s because get-bytevector-n{,!} are specified as blocking if
>> necessary until N bytes are read or EOF is reached.
>
> Ok, the Guile manual description leaves it a ambiguous. Even the R6RS
> wording could be graciously bent slightly to support the age-old
> nonblocking semantics. It boils down to what bytes are considered
> "available." I don't think any nonblocking application would mind those
> functions returning immediately with what they managed to read.

In fact, I think Guile definitely *should* bend the R6RS specification
because:

  1. Guile 2.0's get-bytevector-n(!) does not comply with the strict
     R6RS reading anyway. The Guile implementation comes out with a
     system-error (EAGAIN) exception in case a nonblocking port does not
     have any bytes available at the moment. A strict reading would
     entail spinning in a tight loop, which would be silly, of course.

  2. Partial reads throw a system-error (EAGAIN) and lose the already
     read bytes, which makes Guile's get-bytevector-n(!) completely
     unusable for nonblocking ports.

  3. The R6RS wording suggests nonblocking ports were simply overlooked.
     A looser interpretation could be considered compliant.

So, I think get-bytevector-n(!) could become useful if:

  A. If count bytes are available at the moment, follow the spec (no
     change to Guile 2.0.11).

  B. If eof is encountered, follow the spec (no change to Guile 2.0.11).

  C. If no bytes are available at the moment, a system-error (EGAIN)
     exception is thrown (no change to Guile 2.0.11).

  D. If some but fewer than count bytes are available at the moment,
     transfer those bytes and return the number of bytes transferred.

Only item D is new. Wouldn't implementing it have only positives and no
negatives? In fact, without it, how could nonblocking I/O be carried out
effectively?

Note also get-u8 and get-char, which *are* usefully implemented by Guile
for nonblocking ports but are similarly in violation of R6RS (they don't
block until a byte or complete character is available or eof is
reached).


Marko



  reply	other threads:[~2015-12-07 11:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-06 20:38 Nonblocking get-bytevector-n bug? Marko Rauhamaa
2015-12-07  9:50 ` Ludovic Courtès
2015-12-07 10:21   ` Taylan Ulrich Bayırlı/Kammer
2015-12-07 10:58     ` Taylan Ulrich Bayırlı/Kammer
2015-12-07 14:42       ` Ludovic Courtès
2015-12-08 10:53         ` tomas
2015-12-07 10:28   ` Marko Rauhamaa
2015-12-07 11:15     ` Marko Rauhamaa [this message]
2015-12-07 12:44 ` Amirouche Boubekki
2015-12-07 12:52   ` Marko Rauhamaa
2015-12-08 15:39 ` Mark H Weaver
2015-12-08 17:34   ` Marko Rauhamaa
2015-12-08 19:28     ` Chris Vine
2015-12-08 21:51       ` Marko Rauhamaa
2015-12-08 22:02         ` Marko Rauhamaa
2015-12-09  0:52           ` Chris Vine

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=87610abjd6.fsf@elektro.pacujo.net \
    --to=marko@pacujo.net \
    --cc=guile-user@gnu.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).