@mratsim I have some news about the drawbacks you mentionned I have been working hard to address some issues in my NimGo library. I have implemented custom stacktrace management in debug mode to allow for better debugging: In case of a raise, it is possible to see in a nested way where the errors occurs and who were the caller : 01. include nimgo/coroutines 02. 03.proc myNastyFun(dataMovedAround: string) = 04. raise newException(ValueError, dataMovedAround) 05. 06.proc entryPoint(dataMovedAround: string) = 07. resume(newCoroutine(proc() = 08. myNastyFun(dataMovedAround))) 09. 10.var dataMovedAround = "Hi" 11.var mainCoro = newCoroutine(proc() = entryPoint(dataMovedAround)) 12.resume(mainCoro) Run
Output: Coroutine creation: >/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim(11) test Coroutine execution: >Coroutine creation: >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim(12) test >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim :anonymous >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim(7) entryPoint >Coroutine execution: >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim(12) test >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim :anonymous >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim(7) entryPoint >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim(8) :anonymous >>/home/Aloganit/Coding/NimProject/NimGo/tests/test.nim(4) myNastyFun Error: unhandled exception: Hi [ValueError] Run Verbose and maybe redondant, but still clearer than asyncdispatch. I have also implemented safety mecanisms: 1. now the Coroutines stack is stored alone in its heap memory 2. it uses exclusively Virtual Memory, which makes stackoverflow more difficult 3. It uses a safeguard page at the top of the stack, allowing NimGo to write the relevant message and a stacktrace in most of the time when the stack limit is used . Of course, surface attack can not be inexistent, but now I think unsafe code is will be easier to exploit outside a coroutine than inside one. The resulting cost of creating Coroutines is higher due to those security mecanisms and the use of Virtual Memory, but I still largely acceptable. The author of paper you gave is the creator of the implementation of stackless coroutines in c++, so it is logical he thinks his model is better. However, the cost of function coloring is IMHO just too high for non performance-sensitive usage. I have also found this paper of one of his pear that disagrees with him, you might find it interesting : <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0866r0.pdf>