Sun Dec 22 13:11:14 CET 2019
Compiling CPS state machines
This is very straightforward when the realization is made that a
reified continuation is a sum type, with one clause for each state.
In C using a big ball of mud state struct, this idea is often obscured
because there is usually a lot of sharing between states. I.e. it is
not always clear whether a particular struct member is valid in a
Modeling the continuation as a sum type gets rid of this confusion.
The only downside is then to map this idea efficiently onto a C struct
Rust will probably map very well to this idea.
So essentially there are two parts:
- Convert a blocking task to CPS form
- Represent the continuation sum type efficiently
How close am I getting to async/.await?
That is already performing the CPS transform.
I think I have the perfect example to try this out on. And also the
test: can "loops" and "recursions" be expressed in async/.await?