From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Make get-bytevector-all suspendable. Date: Sun, 16 Jun 2024 15:07:51 +0200 Message-ID: <87frtddoig.fsf@gnu.org> References: <20230720140103.23221-1-mail@cbaines.net> <87bk4lqb85.fsf@gnu.org> <20240601114041.W9gg2C00G4Gw7VF069ghiP@michel.telenet-ops.be> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3336"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: guile-devel@gnu.org To: Maxime Devos Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Jun 16 15:08:30 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sIpcT-0000bj-T5 for guile-devel@m.gmane-mx.org; Sun, 16 Jun 2024 15:08:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sIpc2-0005X7-7Q; Sun, 16 Jun 2024 09:08:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sIpbz-0005Ws-Iw for guile-devel@gnu.org; Sun, 16 Jun 2024 09:08:00 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sIpby-0005dh-As; Sun, 16 Jun 2024 09:07:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=XRrzA0+yHIuJiSRBNWqKP85XhSumvX2lHzAPRjig+F8=; b=i4DX3ZRhcad5Qye7Nu5D s37QcW0Tb9yJf56LQHAPnY2Sr1CCkjmltwSGd0YSdReeB3Mmr0Ba+xGPf9trS7LBi7TUvHwxk+zcc 3uw5QtELWYd/LLn4dDsFkbgeQSvMR8EGnlwB80oN0pnAXemqGZGabmcdPrcukaTU/pzdmnf85pkY3 NsD6XYbusssJUNz9MmRf0/2aDpiN55eT9dN/xm8V0E6SjwquLvevNjK2JIBSQGdH+6Y3jlj/CyNtE KLTbfHSB07ktgottm8dgmYkTXFbbnXJ0+bET9PLwa/ogqw7AV70dRleSUrU/EF0cO+RfpHcyxV1Hs FOt5qXscdBIGmw==; In-Reply-To: <20240601114041.W9gg2C00G4Gw7VF069ghiP@michel.telenet-ops.be> (Maxime Devos's message of "Sat, 1 Jun 2024 11:40:40 +0200") X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Nonidi 29 Prairial an 232 de la =?utf-8?Q?R=C3=A9vol?= =?utf-8?Q?ution=2C?= jour de la Pivoine X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22443 Archived-At: Hi Maxime, Maxime Devos skribis: > It currently is difficult to write a correct implementation of get-byteve= ctor-all in pure Scheme, because =E2=80=98get-bytevector-all=E2=80=99 needs= to return a _fresh_ bytevector and could return twice (e.g. in case of sys= tem-async-mark + call-with-prompt shenanigans). I think the proposed implem= entation is incorrect in this way. Hmm I don=E2=80=99t see how it could return twice. If an async runs while =E2=80=98get-bytevector-all=E2=80=99 is executed, it cannot cause =E2=80=98= get-bytevector-all=E2=80=99 to abort to a prompt. I think we=E2=80=99re fine, no? > +(define (get-bytevector-all port) > + (define %initial-length 4096) > + > + (let read-loop ((total 0) > + (result-length %initial-length) > + (result (make-bytevector %initial-length))) > > I sense a lack of tests for the test suite ... > Also, to avoid avoidable allocations and copying, it would be nice if %in= itial-length could be overridden (optional #:initial-length keyword argumen= t), in case the user has a better guess available. Yeah, but since this interface is specified in R6RS, and since we=E2=80=99re just porting the existing C implementation to Scheme, I=E2=80=99d rather no= t add such a keyword argument. We could provide an extension separately though, as is done for (rnrs bytevectors gnu) for instance. Regarding tests, you=E2=80=99re right: this is already covered. I pushed this as 461ff313fa478d207a7668595e9d976a2ace9770 together with a NEWS entry. Thanks for your feedback! Ludo=E2=80=99.