9 votes

Coroutines for Go

1 comment

  1. skybrian
    Link
    The article explains how coroutines are more expressive than generators (like in Python) while being more efficient than lightweight threads like goroutines. He advocates for a new coroutine...

    The article explains how coroutines are more expressive than generators (like in Python) while being more efficient than lightweight threads like goroutines. He advocates for a new coroutine library for Go that the compiler will do special optimizations on for efficiency.

    A compelling example is the interaction between a scanner and a parser in a compiler. A scanner is more naturally written as sending tokens to the parser, while a parser is more naturally written as pulling tokens from a scanner. With coroutines you can have both. But to do that, the scanner and the parser need their own stacks.

    The context seems to be that now that Go has generics, they are thinking about what to do about generic iterators. How powerful should they be?

    4 votes