From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: anyone define port types? Date: Sun, 19 Jun 2016 17:27:17 +0200 Message-ID: <87fus9kxm2.fsf@pobox.com> References: <87y492mnjp.fsf@pobox.com> <87pots9tag.fsf@gnu.org> <87bn37wtf2.fsf@pobox.com> <20160612092513.3eb1c8a3@laptop.homenet> <8760t5mthu.fsf@pobox.com> <874m8pwlj0.fsf@elektro.pacujo.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1466350168 7962 80.91.229.3 (19 Jun 2016 15:29:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Jun 2016 15:29:28 +0000 (UTC) Cc: Ludovic =?utf-8?Q?Court?= =?utf-8?Q?=C3=A8s?= , guile-devel , guile-user To: Marko Rauhamaa Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jun 19 17:29:14 2016 Return-path: Envelope-to: guile-devel@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 1bEeew-0001nT-16 for guile-devel@m.gmane.org; Sun, 19 Jun 2016 17:29:14 +0200 Original-Received: from localhost ([::1]:39073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEeev-00036n-3W for guile-devel@m.gmane.org; Sun, 19 Jun 2016 11:29:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEedJ-0001Ef-Gf for guile-devel@gnu.org; Sun, 19 Jun 2016 11:27:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEedE-0000Kc-DR for guile-devel@gnu.org; Sun, 19 Jun 2016 11:27:32 -0400 Original-Received: from pb-sasl2.pobox.com ([64.147.108.67]:52844 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEedD-0000KJ-T1; Sun, 19 Jun 2016 11:27:28 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id EFA691FE19; Sun, 19 Jun 2016 11:27:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=qwVH645J3dlvGKEjEkVLyu7PuO8=; b=agdqn0 7kod5FH7Sb1+2aJgtA4LyjIXeC+LQDEQo3csxUyzDK8mY2WqSkE66Qeip8xtFpEk i9ke2DgX+iJ3ecPNE78xnrtsa+YZUN24fyT39ShYWJ7ZPp5HkAHJIzuWeoQPQ8RB E55LVQJBW3ChdWwDFP9OzF2LSfICp4G3qarLA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=sAYuoIWhINe70upy0ywEi8o15hzplVmq pOyYYkJ4IRO7AHV4+Kt2KL5OUMydxShPVKD4j5QH2ETztpEBWRFNxExq7wIipe4O 2swFu4uyL2ZvMz3qfSGYw049AFn7DAIQSjEXcpJRYL60iyXbNdipcIg7aPBL8Oz+ eAboqniD7sM= Original-Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id E711A1FE18; Sun, 19 Jun 2016 11:27:25 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 13E181FE17; Sun, 19 Jun 2016 11:27:24 -0400 (EDT) In-Reply-To: <874m8pwlj0.fsf@elektro.pacujo.net> (Marko Rauhamaa's message of "Sun, 19 Jun 2016 12:55:15 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: 53319A86-3632-11E6-8981-28A6F1301B6D-02397024!pb-sasl2.pobox.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.108.67 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18348 gmane.lisp.guile.user:12651 Archived-At: 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 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