Streaming parsers in D a novel design
Jacob Shtokolov
jacob.100205 at gmail.com
Wed Apr 19 16:07:18 UTC 2023
On Tuesday, 18 April 2023 at 14:26:00 UTC, Sebastiaan Koppe wrote:
> On Tuesday, 18 April 2023 at 08:13:05 UTC, Dmitry Olshansky
> wrote:
>> A streaming parser is doing 2 things:
>> - waiting for input
>> - processing the current input and spitting out Events
>
> I think it will work beautifully until the day you want to do
> it asynchronously.
Ranges can be async, in this case, you just need to return the
Result type (pending|error|success) and provide hints to
something that will be pulling from this range.
It will look like an infinite range, but not fully infinite: it
returns "success" once the result is ready.
The sync version will always return `error|success` without the
'pending' phase.
That kind of interface is similar to Rust's futures, providing
poll-based primitives with some wakeup hints (callbacks).
More information about the Digitalmars-d
mailing list