[[nodiscard]] and KDE coding policy
David Edmundson <[email protected]> Thu, 30 Jul 2026 16:14:44 +0100
| Newsgroups | gmane.comp.kde.devel.general |
|---|---|
| Message-ID | <CAGeFrHB4Ovudh1Tf-D6q=tar3E-h7f_2tu_9Q+JeoHb3qJZC9w@mail.gmail.com> |
I'm seeing more and more merge requests using [[nodiscard]] and now review comments insisting on others adding [[nodiscard]] to new code. I've seen everyone has their own set of rules: - some don't use it - some add it when the return value is important (like opening a file having an error) or when the return value has a RAII pattern or requires the caller to take over memory ownership - some add it to every getter I don't like inconsistency and I don't like repeated discussions on merge requests. I would like to as a group decide on something and add it to https://community.kde.org/Policies/Library_Code_Policy at least for new code with a definitive rule that everyone has to follow. Whether we change existing code is also up for discussion it's a source-incompatible change even though it's binary compatible. We normally avoid source compatible changes, but it shouldn't make too much difference unless we're exposing existing mistakes - which is something we want to do. Any thoughts? David