4 ms·
Coroutines are a hack that is inferior to both real threads (OS supported, true concurrency) and delimited continuations (are functions that multiply instantiat
by kazinator 10y ago
Coroutines are a hack that is inferior to both real threads (OS supported, true concurrency) and delimited continuations (are functions that multiply instantiate, compose and recurse). Both of these mechanisms can easily simulate coroutines.
Many Common Lisp implementations have threads so effectively, Common Lisp de facto supports coroutines.
- codr4life 10y agoI guess you could implement generators and cooperative scheduling (which are useful abstractions with their own strengths, not inferior alternatives to threads) using threads. I never tried myself, but it feels backwards to me; like using 'loop' to iterate a list.
- ScottBurson 10y ago> Coroutines are a hack that is inferior to [...] real threads I don't agree. Sometimes you don't want to pay the price of the OS context switch. Anyway, in the context of the ANSI spec, threads were out of scope, but they could have done coroutines anyway. > ... and delimited continuations But CL doesn't have these, even de facto. Yes, there's CL-Cont, but it's pretty slow.
- codr4life 10y agoI went ahead and brain dumped the most obvious multi-threaded solution I could come up with, to get some performance facts to go with all the rumors. It comes out roughly 5x slower than using conditions/restarts. Just in case someone was wondering where we are atm...