4 ms·
Isn't this kind of thing supported natively with C++ coroutines as of C++20?
by injidup 5y ago
Isn't this kind of thing supported natively with C++ coroutines as of C++20?
- edding4500 5y agoYou mean threading? That is just one common example for what is possible with arbitrary effect handlers.
- pjmlp 5y agoThere is a CppCon talk where they use co-routines to deal with exceptions, Swift style.
- pjmlp 5y agoKind of. You still need a runtime library, which should be integrated by C++23, lets see. What C++ has better than Rust on this regard is that C++20 at least shipped at the necessary vocabulary types and compiler magic, so the plug-and-play story across runtimes (HPX, C++/WinRT, kokos,....) is much more sound today.
- maciejpirog 5y agoOnly to a certain extent. The question is not only if something is possible, but also what the most convenient way to express it is. Effect handlers do have some interesting ideas for programmer-level interface, like user-defined typed commands and dynamic pairing of commands with handlers. In this sense, C++20 coroutines or Boost Context are lower-level, and maybe not the most convenient building blocks for implementing complicated concurrency scenarios, yet alone effects that do not look like concurrency at first sight, like exceptions or different forms of mutable state.
- gpderetta 5y agoThis uses stackful continuations. I.e. you can nest arbitrary code between setting the handler and invoking an effect. With C++ language-level coroutines, everything in between would also need to be a coroutine which doesn't compose as well (i.e. this library doesn't suffer from the colored function problem).