From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: Question about an error with ports Date: Fri, 11 Mar 2022 12:05:00 +0000 Message-ID: <20220311120500.ad94ea6ad79068dc1f8ff85d@gmail.com> References: <3f938fe1-9af4-9076-8d50-d1f7b2ddda36@posteo.de> <87ilslc0gn.fsf@laura> <87fsnpbcbp.fsf@laura> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36707"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Mar 11 13:05:53 2022 Return-path: Envelope-to: guile-user@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 1nSe1o-0009Lk-Ir for guile-user@m.gmane-mx.org; Fri, 11 Mar 2022 13:05:52 +0100 Original-Received: from localhost ([::1]:54562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSe1n-0005SS-3m for guile-user@m.gmane-mx.org; Fri, 11 Mar 2022 07:05:51 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSe16-0005NY-AK for guile-user@gnu.org; Fri, 11 Mar 2022 07:05:08 -0500 Original-Received: from [2a00:1450:4864:20::331] (port=45885 helo=mail-wm1-x331.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSe14-0000jx-Mk for guile-user@gnu.org; Fri, 11 Mar 2022 07:05:08 -0500 Original-Received: by mail-wm1-x331.google.com with SMTP id k29-20020a05600c1c9d00b003817fdc0f00so5188096wms.4 for ; Fri, 11 Mar 2022 04:05:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9WI2qe67NcbmQ8/15D6td7jNxapzI/End5SPBFEJBQw=; b=VkPX2qe6YwQTAwxIDCOwZjv5JBT+3E0LEdSFPjE8BCCWsUhEsZWXD7zqvbFTRXhfCX 5VzVkSHNryKcFvqyiJOh2GfaQC6F/2/e7TTs7Z6XWL/g6WccXiTnX/QKVDZOhPvLIy9O m96VizZyID+0Vp9PU1/XFVg+KqjdUrjCaanya7VF5mccgPIEQ1yDM/+m1Z7slcK2O7EJ rSdZBCltCdd6PpHpTvMJ/crwIVrmY/LgC3iuWaU/RF07wSOyfDmMahahasmAkek78rGx BAOvLqFVf3jnKWuid4NRxjnMGkimDN9L1wqWmA6LHI3IfF0KGfGmaVDV7gl09zpA/SZb LlYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9WI2qe67NcbmQ8/15D6td7jNxapzI/End5SPBFEJBQw=; b=EEn1/zWJEnl9UlfSJk6JrHZSkWh18WP2KFmAhpexiourQod/KOSOzEcgn7vGgGpjwm 8VClJwY1p699SrkHX3UGTCC5ODGofoos8XC25NGLSXrxG7vxKyFLm6NlMNoIdkE9zCJ9 K1/988AJg5vA0j2JYgCOzUgrkbShoDEA0Dst4UfDP7CBVW4sEp9NbXYmxGr1AN9cEhfE TnDtY01VNYRH36YezbV5TwIxWRwX+hFaJ5K1M+u5UWzQhTCAKRO6CfYp33+4pVbUp2MN W7nxw6EKZjU20jMYh3rI4QkPvjLL3z8T9kztNgJaUsB5Ts3kQQ9jMX0Buz1RssaXYK1E zDEQ== X-Gm-Message-State: AOAM530T0DmCc1VWkmszYtWxHnJxnBtfdekHFBznuoviQSPfoDGJj923 Yc21EVTIL6ZNjjokLMAJl5fz6dgFEU4= X-Google-Smtp-Source: ABdhPJx4tpdmi4o9O4YJFnMtJU+ZFfmu1YjX3GPPDCLVTDUhHXeYwlchoYqKwxHcoto6KN00sFrICA== X-Received: by 2002:a7b:c042:0:b0:389:7336:158b with SMTP id u2-20020a7bc042000000b003897336158bmr7476668wmc.15.1647000304721; Fri, 11 Mar 2022 04:05:04 -0800 (PST) Original-Received: from dell.homenet (253.253.9.51.dyn.plus.net. [51.9.253.253]) by smtp.gmail.com with ESMTPSA id bj7-20020a0560001e0700b001f1d7822865sm6290919wrb.43.2022.03.11.04.05.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 04:05:04 -0800 (PST) Original-Received: from dell.homenet (localhost [127.0.0.1]) by dell.homenet (Postfix) with SMTP id 42775427963 for ; Fri, 11 Mar 2022 12:05:00 +0000 (GMT) In-Reply-To: <87fsnpbcbp.fsf@laura> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::331 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=vine24683579@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18183 Archived-At: On Thu, 10 Mar 2022 18:46:34 -0500 Olivier Dion via General Guile related discussions wrote: > On Thu, 10 Mar 2022, Zelphir Kaltstahl wrote: > > > Just one question: Why is get-bytevector-some better than > > get-bytevector-n and specifying a number of bytes? > > I haven't check the implementation details, but I think it's just a > question of buffering. `get-bytevector-n` will block just like > `get-bytevector-some` when the port is empty. The former will return up > to N bytes and the latter might return more than N bytes. The former > probably also lead to less memory allocation since N is known in > advanced, a singled allocation can be made, while the latter might do > multiple allocations. This can be useful depending on your usage of the > port. For example, you could make a web server that only accepts HTTP > body up to 4096 bytes (1 system page). This is what some web server > does I think. > > There's also `get-bytevector-all`, but this would lead to more memory > usage and multiple allocations. Again, it depends on the usage. Avoid using get-bytevector-n!, get-bytevector-some and get-bytevector-all if you are going to use something like fibers or some other asynchronous i/o, as those procedures are not suspendable (they can block). get-bytevector-n (note the difference from get-bytevector-n!) and get-string-all are suspendable and should generally be preferred where suspension is required.