unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Marko Rauhamaa <marko@pacujo.net>
Cc: "Ludovic Courtès" <ludo@gnu.org>,
	guile-devel <guile-devel@gnu.org>,
	guile-user <guile-user@gnu.org>
Subject: Re: anyone define port types?
Date: Sun, 19 Jun 2016 17:27:17 +0200	[thread overview]
Message-ID: <87fus9kxm2.fsf@pobox.com> (raw)
In-Reply-To: <874m8pwlj0.fsf@elektro.pacujo.net> (Marko Rauhamaa's message of "Sun, 19 Jun 2016 12:55:15 +0300")

Hi,

You are arguing for new I/O primitives with different semantics, and
that's fine and good :)  My goal was to add the ability to sensibly work
with non-blocking ports using Guile's existing primitives, especially
the textual ones.

This effort was started because of the ethreads work I did about four
years ago.  That required a separate implementation of buffered ports,
which is fine for a library but not good for a system.  You want to be
able to set a non-blocking port as the current input port, for example,
and you want to be able to (display x p) where p is a non-blocking port,
and you want to be able to do this both in a blocking way, because
Guile doesn't currently include any kind of user-space scheduler, but
also you want to support experiments to make a user-space scheduler.

The ethreads work from four years ago also required me to patch various
parts of Guile, like the web server, so that they could use different
primitives.  That's what I want to avoid.  I want to be able to run an
SSAX parser or a Scheme reader or writer over a non-blocking port and
have it just work.  (For SSAX it's close to working; there are a couple
of primitives that need to be reimplemented in terms of the subset of
port interfaces that suspendable ports replaces.  For Scheme
`read'/`write' the situation is more complicated.)

On Sun 19 Jun 2016 11:55, Marko Rauhamaa <marko@pacujo.net> writes:

> Guile's POSIX support provides immediate access to most OS facilities.
> However, support for read(2) and write(2) seem to be missing. (Note that
> Python, for example, provides both buffered, native facilities and the
> low-level os.read() and os.write().)

A read operation is supported via `get-bytevector-some', but it's true
that `put-bytevector-some' is not implemented.

Incidentally, have you seen ljsyscall, for LuaJIT?  What a great
library.  I wish we had something like that for Guile.

> I haven't thought it through if that callback paradigm would offer the
> same degrees of freedom as the return-whatever-you-have paradigm. It
> seems unnecessarily complicated, though.

There is complication, but it is necessary complication.  If you want to
support blocking textual operations with all of the encodings that Guile
supports over non-blocking ports, you need to be able to poll() when you
get EAGAIN; and if you also want to be able to suspend in the middle of
writing a byte sequence, many levels removed from the original write,
then you need a parameter; and if you don't know yet the entire set of
things you might want to do, that parameter better be a procedure.

In practice I find it a delight to work with this interface.  See the
memcached server and client implementations in the recently updated
wip-ethreads branch; to my eye they are lovely.

Andy



  reply	other threads:[~2016-06-19 15:27 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-28 19:04 anyone define port types? Andy Wingo
2016-03-28 23:53 ` Matt Wette
2016-04-05 14:06   ` Mark H Weaver
2016-04-05 23:55     ` Matt Wette
2016-06-11 16:50       ` Andy Wingo
2016-03-29  7:58 ` tomas
2016-03-29  8:52 ` Nala Ginrut
2016-03-30  6:29 ` Panicz Maciej Godek
2016-03-30 11:18   ` Jan Nieuwenhuizen
2016-03-30 17:17     ` Panicz Maciej Godek
2016-03-30 17:53       ` Marko Rauhamaa
2016-03-30 19:02         ` Panicz Maciej Godek
2016-03-30 19:57           ` Marko Rauhamaa
2016-03-31 16:11             ` Barry Fishman
2016-03-31 19:28               ` Marko Rauhamaa
2016-03-30 19:43         ` Jan Wedekind
2016-03-30 20:07           ` Marko Rauhamaa
2016-03-30 21:01             ` Jan Wedekind
2016-03-30 22:44               ` Marko Rauhamaa
2016-03-31 20:42                 ` Jan Wedekind
2016-03-31 22:28                   ` Marko Rauhamaa
2016-06-11 16:53   ` Andy Wingo
2016-04-01 14:38 ` Ludovic Courtès
2016-06-11 16:57   ` Andy Wingo
2016-04-14 14:08 ` Ludovic Courtès
2016-06-11 17:02   ` Andy Wingo
2016-06-12  8:25     ` Chris Vine
2016-06-19  9:13       ` Andy Wingo
2016-06-19  9:55         ` Marko Rauhamaa
2016-06-19 15:27           ` Andy Wingo [this message]
2016-06-19 15:33         ` Chris Vine
2016-06-19 17:48           ` Andy Wingo
2016-06-19 20:09             ` Chris Vine
2016-06-20  3:38               ` William ML Leslie
2016-06-20  6:45                 ` Chris Vine
2016-06-20  7:34                   ` Andy Wingo
2016-06-20  9:01                     ` Chris Vine
2016-06-22 22:44                       ` Chris Vine
2016-06-23  7:36                         ` Andy Wingo
2016-06-23  8:56                           ` Andy Wingo
2016-06-23  9:24                           ` Chris Vine
2016-06-23  9:50                             ` Marko Rauhamaa
2016-06-23 10:43                             ` Andy Wingo
2016-06-23 11:49                               ` William ML Leslie

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=87fus9kxm2.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=ludo@gnu.org \
    --cc=marko@pacujo.net \
    /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).