On Fri, May 10, 2024 at 12:22 AM Arno Schoedl via Boost < boost@lists.boost.org> wrote:
Is there a way to avoid std::for_each having to be a coroutine?
No. This blog post elegantly relates the problem with this design (I think). https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ The viral nature of co_await was understood in 2015 and described in P0158R0: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0158r0.html Most of the problems predicted in P0158R0 before coroutines made it into the standard are now being reported independently by users. As I noted in my previous replies, there is no process in WG21 which revisits major language decisions to learn from mistakes. In fact... I remember when the author was lobbying hard for coroutines he was giving talks, going to lunches and dinners, posting on reddit, posting on the Official C++ Language Slack Workspace, hanging out in Discord, and so on. But after coroutines made it into the standard he disappeared faster than my ex-wife after I declared bankruptcy. He unlocked the achievement I suppose. If it sounds like I'm picking on the author, I am not. If he didn't do it, someone else would have. The WG21 process incentivizes this behavior. Land a high-profile feature desired by a corporate sponsor, and game over. It isn't a coincidence that C++ coroutines harmonize perfectly with their C# equivalent (Microsoft). Here's a blog post from a user describing their experience. If you look at items 1, 2, and 3 under 'Conclusion' you can see that this was exactly predicted in opposition papers pre-acceptance. Thanks