Single Thread Continuation

Robert Engels rengels at ix.netcom.com
Wed Jul 5 14:58:07 UTC 2023


I didn’t say that generators aren’t useful - I only stated that Java does not need any language changes to implement them correctly and efficiently. 

> On Jul 5, 2023, at 9:53 AM, Pedro Lamarão <pedro.lamarao at prodist.com.br> wrote:
> 
> 
>> Em qua., 5 de jul. de 2023 às 10:56, Paul Bjorkstrand <paul.bjorkstrand at gmail.com> escreveu:
>>  
>> I will bring it back to the challenge I gave to those wanting generators, exposed continuations, or custom schedulers for virtual threads: show why it is needed!
> 
> The main benefit of having generators is aligned to one of the most common highlights for using virtual threads:
> representing control flow directly, instead of doing state machines.
> In the virtual thread case, this is all about asynchronous I/O; in the generator case, this is all about complex data formats.
> Today, in order to process complex data formats, you either parse and generate an object for the entire data in one go (like DOM), or you parse and generate a stream pushing elements to callbacks that require your user to maintain a state machine (like SAX), or returning elements by maintaining an internal state machine (like XMLReader).
> Only with the last, reader-like, design, parsers are easily composable -- by doing higher level parsers that consume suppliers of elements from a lower level parser.
> But debugging these is hard, for the very same reason that debugging state-mechine-style asynchronous I/O programs is hard -- one must somehow follow the state transitions manually.
> With generators, reader-like parsers can be written in the subroutine-style with no loss of efficiency.
> 
> -- 
> Pedro Lamarão
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230705/b4f7bacb/attachment.htm>


More information about the loom-dev mailing list