From: Maxime Devos <maximedevos@telenet.be>
To: "mikael@djurfeldt.com" <mikael@djurfeldt.com>,
Nala Ginrut <nalaginrut@gmail.com>
Cc: Adam Faiz <adam.faiz@disroot.org>,
guile-devel <guile-devel@gnu.org>,
Ricardo Wurmus <rekado@elephly.net>, Tomas Volf <~@wolfsden.cz>
Subject: RE: [PATCH] test-suite: Add tests for `for-rdelim-in-port`-related functions.
Date: Fri, 20 Dec 2024 10:15:30 +0100 [thread overview]
Message-ID: <20241220101533.qxFY2D00e2kJuzj01xFZgG@baptiste.telenet-ops.be> (raw)
In-Reply-To: <CAA2XvwKqVe+dDFAnkOGE-+Co8aF1SFnLFC+_qT2r1LJ0d92fhw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2240 bytes --]
>I think these procedures are handy in common situations. There has been a discussion about generalization. I have the feeling that such generalization either already exists in some SRFI or that one should put some deep thinking into how to represent flexible iteration in Scheme.
If one should put some deep thinking in how to represent flexible iteration, this almost equally applies to ‘for-rdelim-in-port’ too. All that might be different is ‘read-line’ and maybe ‘eof-object?’ being replacable, all other flexibility is independent on whether to generalise or not. Nowhere in this thread have I seen deep thinking about whether for-delimited-in-port should be some stream-like API, fold or reduce and whether there should be some early stop conditions.
About SRFI: the closest thing I found is port-transduce, but in most cases this seems to be an overgeneralisation. If you want some super general thing, you can use the SRFI or implement your own, if all you need is to _iterate_ a (for-object-in-port [reader] [proc] [port]) is much simpler to use and further generalisation (except maybe for eof condition checking) gets in the way.
>I don't think it would be bad to apply Adam's patch, though, or that placing it in (ice-9 rdelim) is unnatural.
Nobody claimed that its location was unnatural, and not being bad doesn’t mean it cannot be improved.
>If no one objects, I will apply the patch in a couple of days with the current naming scheme but modified by the following:
I do.
>+ (let ((port (open-output-file filename)))
Please don’t, a string output port is much cleaner. Avoids all issues with file I/O.
>+ (pass-if "for-line-in-file returns true upon completion"
>+ (for-line-in-file filename
>+ (lambda (line)
>+ (set! lines (cons line lines))))
>+ (equal? lines '("line3" "line2" "line1"))))
This ‘true upon completion’ is undocumented.
I don’t see a reason for it to return anything.
Also, you are assuming “\n” is a line delimiter. This is true under Unix according to the documentation. But it doesn’t say anything about non-Unix systems.
Best regards,
Maxime Devos
[-- Attachment #2: Type: text/html, Size: 5055 bytes --]
next prev parent reply other threads:[~2024-12-20 9:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 15:21 [PATCH 1/2] rdelim: Add new procedure `for-rdelim-in-port` Adam Faiz
2024-12-16 15:24 ` [PATCH 2/2] doc: Add documentation for `for-rdelim-in-port` and, related procedures Adam Faiz
2024-12-17 4:31 ` [PATCH] test-suite: Add tests for `for-rdelim-in-port`-related functions Adam Faiz
2024-12-17 5:11 ` Nala Ginrut
2024-12-17 7:21 ` Mikael Djurfeldt
2024-12-17 16:43 ` Mikael Djurfeldt
2024-12-20 9:15 ` Maxime Devos [this message]
2024-12-20 9:57 ` Nala Ginrut
2024-12-20 11:51 ` Maxime Devos
2024-12-20 12:00 ` Nala Ginrut
2024-12-20 12:53 ` Maxime Devos
2024-12-20 13:00 ` Nala Ginrut
2024-12-20 13:45 ` Maxime Devos
2024-12-20 13:52 ` Nala Ginrut
2024-12-20 14:18 ` Maxime Devos
2024-12-20 14:30 ` Nala Ginrut
2024-12-20 14:32 ` Nala Ginrut
2024-12-20 14:47 ` Maxime Devos
2024-12-20 14:56 ` Nala Ginrut
2024-12-20 15:07 ` Maxime Devos
2024-12-20 15:13 ` Nala Ginrut
2024-12-19 21:50 ` Mikael Djurfeldt
2024-12-20 15:15 ` [PATCH] test-suite: Add tests for `for-rdelim-in-port`-relatedfunctions Maxime Devos
2024-12-20 17:11 ` Mikael Djurfeldt
2024-12-20 17:31 ` Nala Ginrut
2024-12-20 18:40 ` Maxime Devos
2024-12-16 16:46 ` [PATCH 1/2] rdelim: Add new procedure `for-rdelim-in-port` Nala Ginrut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241220101533.qxFY2D00e2kJuzj01xFZgG@baptiste.telenet-ops.be \
--to=maximedevos@telenet.be \
--cc=adam.faiz@disroot.org \
--cc=guile-devel@gnu.org \
--cc=mikael@djurfeldt.com \
--cc=nalaginrut@gmail.com \
--cc=rekado@elephly.net \
--cc=~@wolfsden.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).