As for ‘compiler’ you also don’t need to go all the way to bare metal, some runtime like WASM or the JVM which is more civilized is a good target these days.
As for ‘compiler’ you also don’t need to go all the way to bare metal, some runtime like WASM or the JVM which is more civilized is a good target these days.
That is, a lot of why you would go with macros in the past was to avoid the expense of function calls. Right? We have so far left the world of caring about function call overhead for most projects, that it is hard to really comprehend.
Coroutines still strike me as a hard one to really grok. I remember reading them in Knuth's work and originally thinking it was a fancy way of saying what we came to call functions and methods. I think without defining threads first, defining a coroutine is really hard to nail down. And too many of us take understanding of threads as a given. Despite many of us (myself not immune) having a bad understanding of threads.
That is, a basic class that has defined state and methods to modify the state is already enough to explain a state machine. What makes coroutines better for it?
> the state is already enough to explain a state machine.
I did not talk about explaining state machines but implementing state machines as coroutines. Progression: give an idea of state machines, show how hard is to handle state, present coroutines as way to handle states.
Also, there's always plenty of use for doing work at compile time.
In some sense they can also be seen as a better code generation.