Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Protothreads is a pretty cool concept and I'm sure many people have done amazing things with it, but it's the sort of extreme usage that often gives these hacks a bad name. When you build your whole application around a hack like that you put yourself into a corner in terms of code reuse (inbound and outbound), difficulty onboarding contributors (possibly including yourself after a hiatus), etc.
I'm a prolific user of Duff's device as a poor man's coroutine in C, but in non-toy applications I do try to isolate the behavior entirely within a simple, conventional API as much as I can, for example by implementing a simple iterator using a generator pattern as in https://github.com/wahern/lunix/blob/master/src/unix-getopt.... IOW, I'm not trying to encapsulate the magic in a library abstraction so it can be reused (and abused) everywhere; my primary concern is isolating the functional usage.