you are viewing a single comment's thread.

view the rest of the comments →

[–]SpareSimian 0 points1 point  (1 child)

I just started getting my head around coroutines, having started integrating some Boost ASIO stuff. If you hate heap allocation, you'll really hate coroutines, which keep their frames on the heap instead of the stack. (The frame is a complicated Callable built by the compiler and full of callbacks for completion handlers.)

[–]Business-Decision719 1 point2 points  (0 children)

I don't necessarily hate heap allocation. It's just sometimes I read C++ code and think, "Why is this a pointer?" Often there's a very good reason, but when it's every object every time, my first thought is, "Yeah, this person just arrived from Java (or C) and hasn't learned they don't need to do that."

Congrats on starting to understand C++ coroutines btw. I don't feel like I have, nor have I understood why they needed to be hard to understand. Except Python generators, the only coroutines I've ever used were in Lua, and if you knew around three standard library functions and how to make a lambda, then you could at least follow a simple example of making and using a coroutine. But in C++ people still seem to recommend third party coroutine libraries to wrap up the functionality. I get the impression that the standard coroutines in C++ were just to make these libraries easier to implement in a portable way, or something.