Of interest only to my computer science friends who know and love C very well. I thought after over 30 years of…

Of interest only to my computer science friends who know and love C very well. I thought after over 30 years of using the language I had already seen every perversion and depravity possible in C, and yet, here’s a new one to me: you can abuse Duff’s Device plus macros to get co-routines. (The side effect may be to summon the old ones though.)

Apparently this was originally discovered by Tom Duff and he thought it was too disgusting to describe in his original Usenet posting on Duff’s Device. Simon Tatham’s “PuTTY” actually uses it throughout!

http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html