4 ms·
> (Actually, I have another revolting way to use switches to implement interrupt driven state machines but it's too horrid to go into.) I'm really, really cur
by AceJohnny2 11y ago
> (Actually, I have another revolting way to use switches to implement interrupt driven state machines but it's too horrid to go into.)
I'm really, really curious about what that code is.
- mikeash 11y agoThis is just a guess, but perhaps something like: http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
- jhallenworld 11y agoThis is a very useful technique for making event driven parsers. I remember being surprised that the case statements didn't all have to be in the same scoping level, but it's true.
- nraynaud 11y agoI just used it a few minutes ago: https://github.com/nraynaud/webgcode/blob/gh-pages/interpolator/main.c#L150 https://github.com/nraynaud/webgcode/blob/gh-pages/interpola... https://github.com/nraynaud/webgcode/blob/gh-pages/interpolator/cnc.h#L111 https://github.com/nraynaud/webgcode/blob/gh-pages/interpola... One problem is the reset of the functions, I just created a makeshift exception, but I don't know how far I want to deviate form the norm. I still don't know if it's a good idea, but that's what personal projects are for.