|
|
|
|
|
by lixiasky
126 days ago
|
|
That is a fascinating comparison! History really does rhyme.
What you described—suspending with a flag and resuming with new values—is surprisingly similar to how the C++20 compiler transforms coroutines into a state machine under the hood.
In tiny_coro, the promise_type essentially manages that "inversion of control" you mentioned, but hides the manual state management behind the co_await syntax. It's really cool to see that these fundamental patterns for "stopping and resuming" computation have existed for so long, just in different forms. |
|
It's easier in C and old C++ if one can drop down to assembly to switch between different call stacks.
Among modern languages there is Lua. Take a look at Felix too.
https://felix-tutorial.readthedocs.io/en/latest/tut110.html
https://felix.readthedocs.io/en/latest/fibres.html