From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: Continuations in custom port: "cannot invoke continuation from this context" Date: Wed, 17 Apr 2019 20:47:33 -0400 Message-ID: <87h8aw3zr3.fsf@netris.org> References: <87wokj1v06.fsf@cune.org> <87o95q6qc7.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="172439"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: guile-user@gnu.org To: Caleb Ristvedt Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Apr 18 02:49:41 2019 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGvFF-000ih5-3l for guile-user@m.gmane.org; Thu, 18 Apr 2019 02:49:41 +0200 Original-Received: from localhost ([127.0.0.1]:33491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGvFD-000164-Su for guile-user@m.gmane.org; Wed, 17 Apr 2019 20:49:39 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGvEt-00015v-3O for guile-user@gnu.org; Wed, 17 Apr 2019 20:49:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGvEp-00004v-7C for guile-user@gnu.org; Wed, 17 Apr 2019 20:49:18 -0400 Original-Received: from world.peace.net ([64.112.178.59]:55326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGvEm-0008SZ-1G for guile-user@gnu.org; Wed, 17 Apr 2019 20:49:13 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hGvEi-0003qJ-SA; Wed, 17 Apr 2019 20:49:08 -0400 In-Reply-To: <87o95q6qc7.fsf@netris.org> (Mark H. Weaver's message of "Mon, 01 Apr 2019 05:12:45 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.112.178.59 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:15397 Archived-At: Hi Caleb, Earlier I wrote: > Caleb Ristvedt writes: > >> On Thu, Mar 28, 2019 at 12:58 PM Stefan Israelsson Tampe < >> stefan.itampe@gmail.com> wrote: >> >>> I have not looked at this more carefully. But I suspect that the code is >>> going to C land and then enters the scheme again >>> via the hooks and then continuations won't work as expected. > >> Any idea why it would still be going to C land even with suspendable ports >> installed? The manual says they're implemented in scheme for precisely this >> reason. > > 'install-suspendable-ports!' replaces only a subset of the C port > functions with Scheme implementations, namely the ones listed in > 'port-bindings' in suspendable-ports.scm. > > The problem here is the custom port. Custom ports are implemented in C, > and are not reimplemented by suspendable-ports.scm. When you perform > I/O on the custom port, it enters C code in r6rs-ports.c which calls > back into Scheme code to call your custom I/O handlers 'read!' and > 'write!'. Since writing this, I've written preliminary patches to add suspendable I/O support for custom ports: https://lists.gnu.org/archive/html/guile-devel/2019-04/msg00019.html I'd be curious to hear how it works in your use case. Mark