Skip to content

Implement Bidirectional Coroutines #2

@nikhedonia

Description

@nikhedonia

Example:

auto pingPong = [](int x) -> reactor<int, int> {
   while(1) {
     x =  co_yield x;
   }
};

int main() {
  auto actor = pingPong(1);
  auto value = 0;
  while( actor.next(value) ) {
    value = actor.value() + 1;
   }
}

This can be later used to implement:

  • Haskell like io-monads
  • elm like effect systems
  • event-loops
  • parser combinators

PoC: https://godbolt.org/z/AW3UWC

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions