Skip to content

Implement Bidirectional Coroutines #2

Open
@nikhedonia

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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