From: Nala Ginrut <nalaginrut@gmail.com>
To: Maxime Devos <maximedevos@telenet.be>
Cc: Adam Faiz <adam.faiz@disroot.org>,
"guile-devel@gnu.org" <guile-devel@gnu.org>,
Ricardo Wurmus <rekado@elephly.net>
Subject: Re: [PATCH v2] rdelim: Add new procedure `for-line-in-file`.
Date: Mon, 16 Dec 2024 20:06:41 +0900 [thread overview]
Message-ID: <CAPjoZodKS+8W2qhjRyiQcSYqGAVuwSDSWVEQLpsmrmS5v=TV1A@mail.gmail.com> (raw)
In-Reply-To: <20241216115207.pNs52D00j1dDhme01Ns6nW@baptiste.telenet-ops.be>
[-- Attachment #1: Type: text/plain, Size: 3654 bytes --]
I'm not going to pursued anyone here, just sharing my opinion about a patch
for line parsing in a text file.😄
Yes, some of the parsers don need backwards, but it also doesn't mean
others parsers have priority to occupy a general API.
To my experience, a parser author like me prefer to write own parser from
scratch for many reasons, rather than finding ans adapting to a general
function buried deep under document.
Here's my opinion, as a parser writer, I have no interest to use it, but I
can say it still looks beautiful from functional programming perspective.
Beauty is still a value worth to go. I can agree with this. But I don't use
this function.
Of course I speak only for myself as a potential existing user.
So if we can be back to the original topic, a patch for parsing text line
function that can be understand and reviewex easy by most people. I believe
the author's effort and my suggestions are well enough to go. 😄
This doesn't mean I against your idea.
Best regards.
On Mon, Dec 16, 2024, 19:52 Maxime Devos <maximedevos@telenet.be> wrote:
> >You raised this topic from string line reading to more general case. 😄
>
>
>
> Yes.
>
> >If so, the best way could be providing a general function to wrap rdelim
> for for-each-seg-delim, users may pass a delimiter to decide how to delim
> (even for bytevectors), and implement for-line-a-file base on it with
> unicode encoding.
>
> No, this is worse. This limits the procedure to delimiting.
>
> >However, personally I dare to doubt if we really need such general
> function, since general parsing may require looking backwards. This implies
> the char based checking delimiter will be more general.
> If we don't consider this, it's better to just consider strings with
> proper encoding to avoid over engineering.
>
> 'general parsing may require looking backwards’ does not imply ‘don’t need
> such general function’, and ‘don’t need such general function’ doesn’t
> imply ‘such a general function wouldn’t be useful’. Many parsers don’t need
> looking backwards. E.g., see all examples I mentioned in my mail.
>
> Also, you ‘general’ isn’t my ‘general’. Nowhere did I limit the procedure
> to delimiters and character-based things.
>
> For an example on how this could be used: in Scheme-GNUnet, a fiber is
> waiting on messages on some (stream) socket (SOCK_STREAM, not SOCK_DGRAM).
> Each message consists of ‘message type field + packet size field +
> information’. So, the fiber effectively iterates over all messages on the
> stream. The parser first reads the type and size (no looking backwards
> needed), then reads the remaining information and passes this information
> to the type-specific parser, which can now be acted upon.
>
> (IIRC, the control flow is technically a bit different (let loop with
> arguments, to avoid mutation, not that it really matters since there is
> state anyway in the ports), but it could have been implemented like this
> instead.)
>
> Copy of list of examples that don’t need looking backwards:
>
> This is overly specific to reading lines, and reading lines with rdelim.
> If you replace ‘read-line’ by an argument, the procedure becomes more
> general. For example, by passing ‘get-char’ you can act on each character,
> with ‘get-line’ I’m not sure what the difference would be, but apparently
> it’s not ‘read-line’ (?), if you give it a JSON reading+parsing proedure
> you iterate over all JSON objects, with get-u8 you iterate over bytes etc..
>
> Best regards,
> Maxime Devos
>
[-- Attachment #2: Type: text/html, Size: 5212 bytes --]
next prev parent reply other threads:[~2024-12-16 11:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 6:14 [PATCH v2] rdelim: Add new procedure `for-line-in-file` Adam Faiz
2024-12-16 7:41 ` Nala Ginrut
2024-12-16 10:17 ` Maxime Devos
2024-12-16 10:29 ` Nala Ginrut
2024-12-16 10:52 ` Maxime Devos
2024-12-16 11:06 ` Nala Ginrut [this message]
2024-12-16 12:00 ` Maxime Devos
2024-12-16 12:33 ` 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='CAPjoZodKS+8W2qhjRyiQcSYqGAVuwSDSWVEQLpsmrmS5v=TV1A@mail.gmail.com' \
--to=nalaginrut@gmail.com \
--cc=adam.faiz@disroot.org \
--cc=guile-devel@gnu.org \
--cc=maximedevos@telenet.be \
--cc=rekado@elephly.net \
/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).