2006-09-09

Coroutines in C

While browsing for something, I can't recall what, I found a page on coroutines in C by a guy named Simon Tatham. The implementation uses funky macros and gotos to get things working. Ouch, that could really be offensive to some people.

Then there's the infamous "Duff's Device", which was mentioned in Bjarne Stroustrup's The C++ Programming Language book. The reason it came up in relation to coroutines is that it does indeed use the switch structure as a screwy means of goto.

Well, everyone should just give up and use state machines.

No comments: