sustrik / libdill

Structured concurrency in C
MIT License
1.68k stars 156 forks source link

Question: Why not portable switch-based coroutine switching? #205

Closed mentalisttraceur closed 4 years ago

mentalisttraceur commented 4 years ago

I have been trying to understand the various design decisions behind libdill, and I was wondering why you did not go for the switch-based C coroutine technique described here and used in libraries like protothreads?

The obvious advantage would be much broader C portability, since it just uses standard C features, without relying on any modern compiler extensions. I presume there was a less obvious disadvantage that outweighed that?

Have you ever written about this on your blog or anywhere else?

If someone were to try to write a libdill starting from that technique, what are the specific issues they would run into that are insurmountable or that would tip the balance in favor of the way you did it?

sustrik commented 4 years ago

That would mean that everyone would have to start using very different coding paradigm (having no stack, etc.) 99% of users don't want to give that up.

mentalisttraceur commented 4 years ago

Oh, yeah, that seems obvious now that you drew my attention to it. Thanks!