From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: RE: [PATCH v2] rdelim: Add new procedure `for-line-in-file`. Date: Mon, 16 Dec 2024 11:17:21 +0100 Message-ID: <20241216111722.pNHK2D00E1dDhme01NHKfE@andre.telenet-ops.be> References: <0c0bc19c-9b46-4da7-b200-3de0355949fa@disroot.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_8C767799-8BB8-4C30-B56E-0F0492ADF585_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40099"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Nala Ginrut , Ricardo Wurmus To: Adam Faiz , "guile-devel@gnu.org" Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Mon Dec 16 11:18:02 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 1tN8Ar-000ABt-El for guile-devel@m.gmane-mx.org; Mon, 16 Dec 2024 11:18:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tN8AN-00076C-HQ; Mon, 16 Dec 2024 05:17:31 -0500 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 1tN8AL-00075d-NN for guile-devel@gnu.org; Mon, 16 Dec 2024 05:17:29 -0500 Original-Received: from andre.telenet-ops.be ([2a02:1800:120:4::f00:15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tN8AJ-0001gj-Ak for guile-devel@gnu.org; Mon, 16 Dec 2024 05:17:29 -0500 Original-Received: from [IPv6:2a02:1811:8c0e:ef00:2ca3:f220:8d70:df09] ([IPv6:2a02:1811:8c0e:ef00:2ca3:f220:8d70:df09]) by andre.telenet-ops.be with cmsmtp id pNHK2D00E1dDhme01NHKfE; Mon, 16 Dec 2024 11:17:21 +0100 Importance: normal X-Priority: 3 In-Reply-To: <0c0bc19c-9b46-4da7-b200-3de0355949fa@disroot.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r24; t=1734344242; bh=CmLlGpTv4cM6zZ4im0JLaSmRhpq/O9ark4PN2CvLaqM=; h=Message-ID:MIME-Version:To:Cc:From:Subject:Date:In-Reply-To: References:Content-Type:From; b=l5E2tqImpEIxKRjktxO3BoRvZZg/KnHu8pMX+yq23Dvu+UajcRPb5l4qk196kpg3n afuxn/sHY9Z0QR7YgL19nGMwRtns9W7CSFOyiDaLaPiakjmZOKzun3oQca5JvkXeCW 5gz3xFfJZ+tiYZ5GZsLPz9DsJRHoiTy+yy82uKVjZNMA2XfJvXTg0FfbhKzeX3xMDZ 0SEcDGzkcDydWOtZx7FoLyUdQ1BpH8RkxJ1NCDuuEw9WLYzzX8+ru5zLmkwFWa02U7 4FBO4HBzm3jj16YqTRwcdCnrgyp04z2BxCVXzO8szm8UFSOn/lr+qUTEHT6mnZXFVp z0Q3n9iYpQKGQ== Received-SPF: pass client-ip=2a02:1800:120:4::f00:15; envelope-from=maximedevos@telenet.be; helo=andre.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:22822 Archived-At: --_8C767799-8BB8-4C30-B56E-0F0492ADF585_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is overly specific to reading lines, and reading lines with rdelim. If= you replace =E2=80=98read-line=E2=80=99 by an argument, the procedure beco= mes more general. For example, by passing =E2=80=98get-char=E2=80=99 you ca= n act on each character, with =E2=80=98get-line=E2=80=99 I=E2=80=99m not su= re what the difference would be, but apparently it=E2=80=99s not =E2=80=98r= ead-line=E2=80=99 (?), if you give it a JSON reading+parsing proedure you i= terate over all JSON objects, with get-u8 you iterate over bytes etc.. You could then define =E2=80=98for-line-in-file=E2=80=99 (for-line-in-port?= ) as a special case of the more general procedure. This generalisation also allows for setting =E2=80=98handle-delim=E2=80=99,= which currently you are not allowing (the user still shouldn=E2=80=99t cho= ose =E2=80=98split=E2=80=99 though). I=E2=80=99m not sure where the general port interface should be, maybe in h= ttps://www.gnu.org/software/guile/manual/html_node/Ports.html? (Slightly more general is to also move eof-object? into an argument, but th= at seems too much generalisation. OTOH, it allows for =E2=80=98split=E2=80= =99.) Also, I=E2=80=99d rather keep opening files out of the procedure =E2=80=93 = avoids the text encoding issues (mentioned by Nala Ginrut), also convenient= for sandboxed environment that don=E2=80=99t want to give access to the fi= le system (or, at least, only use a special file opening procedure that doe= s additional checks), and avoids conflation of file names with files and fi= les with ports. (As written, it=E2=80=99s for file ports, but as implemente= d, it can be meaningfully used for other ports as well (e.g. networking soc= kets).) (Also the user might want to set CLOEXEC or other flags, or uncompr= ess input, =E2=80=A6) Also, documentation is missing. Best regards, Maxime Devos --_8C767799-8BB8-4C30-B56E-0F0492ADF585_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

=  

This is overly specific to reading lines, and reading lines wit= h rdelim. If you replace =E2=80=98read-line=E2=80=99 by an argument, the pr= ocedure becomes more general. For example, by passing =E2=80=98get-char=E2= =80=99 you can act on each character, with =E2=80=98get-line=E2=80=99 I=E2= =80=99m not sure what the difference would be, but apparently it=E2=80=99s = not =E2=80=98read-line=E2=80=99 (?), if you give it a JSON reading+parsing = proedure you iterate over all JSON objects, with get-u8 you iterate over by= tes etc..

 

You could t= hen define =E2=80=98for-line-in-file=E2=80=99 (for-line-in-port?) as a spec= ial case of the more general procedure.

 

= This generalisation also allows for setting =E2=80=98han= dle-delim=E2=80=99, which currently you are not allowing (the user still sh= ouldn=E2=80=99t choose =E2=80=98split=E2=80=99 though).

 

I=E2=80=99m not sure where the general p= ort interface should be, maybe in https://www.gnu.org/software/guile/manual= /html_node/Ports.html?

 

(Slightly more general is to also move eof-object? into an argument, = but that seems too much generalisation. OTOH, it allows for =E2=80=98split= =E2=80=99.)

 

Also, I= =E2=80=99d rather keep opening files out of the procedure =E2=80=93 avoids = the text encoding issues (mentioned by Nala Ginrut), also convenient for sa= ndboxed environment that don=E2=80=99t want to give access to the file syst= em (or, at least, only use a special file opening procedure that does addit= ional checks), and avoids conflation of file names with files and files wit= h ports. (As written, it=E2=80=99s for file ports, but as implemented, it c= an be meaningfully used for other ports as well (e.g. networking sockets).)= (Also the user might want to set CLOEXEC or other flags, or uncompress inp= ut, =E2=80=A6)

 

Also, = documentation is missing.

 

Best regards,
Maxime Devos

= --_8C767799-8BB8-4C30-B56E-0F0492ADF585_--