News for hackers. Stuff that matters.

hannes_s

Re:The Downsides of C++ Coroutines on Sunday August 13, 2023 @06:02AM (#37108386)
One problem I have with C++ coroutines is the implicit capture of the "this" pointer in member functions. One can also accidentally pass arguments by reference resulting in lifetime issues, but at least the parameter types are explicitly stated.

The post mentions that it might be the caller's or the callee's responsibility to keep the object alive until the end of the coroutine. This is purely based on conventions however, and different libraries might have different conventions. If the caller is responsible for it, extra care needs to be taken whenever the function is called -- the code shown in the post seems fairly complex to me and easy to get wrong. Also, I am not sure how the callee could safely implement keeping the object alive if lazy coroutines are used: Even if the first statement in the coroutine is retaining a strong reference on the object, there might still be a time between the call and the initial resume of the coroutine where the object is destroyed. I think it would have been great to provide explicit capture lists for coroutines, similar to lambdas.

All of this gets especially confusing once you try to use lambdas together with coroutines. AFAIK, C++ lambdas are basically just structs overloading operator(). In a coroutine, only the "this" pointer of the structure is captured and the caller needs to ensure that the object is not only alive, but also at the same memory address until the end of the coroutine. This is very easy to get wrong in my experience.

Re:Show HN: Fluent Feeds – A feed reader for Windows 11 on Monday August 29, 2022 @12:24PM (#32640076)
There are two key differences between the syndication feed provider and the HN provider:

- The content type: The syndication feed provider only supports "article" content which is just a string with rich text formatting. The HN feed provider allows Fluent Feeds to download and display the complete comment tree for every item right inside the app.

- The content storage: When a syndication feed is synchronized, its complete content is stored in a local database – including the item content. This is not necessary for the HN feed provider as it loads the comments using the API whenever the user selects the item for the first time or when the user manually reloads the content.

In addition, the HN feed provider is a demonstration of the app's modular approach. Once plugin support is implemented, it will probably be provided as a separate plugin that can be added by the user.