Skip to content

remove exceptions#23

Open
koonpeng wants to merge 13 commits intokp/job-managerfrom
kp/ban-exceptions
Open

remove exceptions#23
koonpeng wants to merge 13 commits intokp/job-managerfrom
kp/ban-exceptions

Conversation

@koonpeng
Copy link
Copy Markdown
Member

@koonpeng koonpeng commented Nov 9, 2023

This is a preview of the work in removing exceptions.

Inspired from rust, Result<T> is the alternative to exceptions. Internally it uses std::variant to store either the result or a std::exception.

  • [[nodiscard]] should almost always be used when returning Result<T>. We don't have custom lint rules so it will have to be checked manually.
  • Result<void> is a special case that using std::optional instead.
  • One downside is that we cannot return a reference, Result<T&> does not work because std::variant cannot contain references.
    • In theory should be able to specialize Result<T> for all reference types and store a pointer internally instead.

@koonpeng koonpeng marked this pull request as draft November 9, 2023 07:55
@koonpeng koonpeng requested a review from Yadunund November 9, 2023 07:55
@koonpeng koonpeng changed the base branch from main to kp/job-manager November 9, 2023 08:20
@koonpeng koonpeng changed the title WIP remove exceptions remove exceptions Nov 20, 2023
@koonpeng koonpeng marked this pull request as ready for review November 20, 2023 02:56
@koonpeng
Copy link
Copy Markdown
Member Author

Integration test is working with the latest release of ros2 iron, but the docker images are not updated yet.

@Yadunund
Copy link
Copy Markdown
Member

Yadunund commented Dec 4, 2023

Could you merge the latest main into the base branch also rebase/update this branch?

Teo Koon Peng added 11 commits November 27, 2024 12:43
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
@luca-della-vedova
Copy link
Copy Markdown
Member

I'm wondering, especially now that we bumped main to 24.04 and all the compiler versions are fairly recent, would it make sense to increase our C++ standard to C++23 and use std::expected rather than manually implementing our own Result type?

Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
@koonpeng
Copy link
Copy Markdown
Member Author

koonpeng commented Dec 3, 2024

I'm wondering, especially now that we bumped main to 24.04 and all the compiler versions are fairly recent, would it make sense to increase our C++ standard to C++23 and use std::expected rather than manually implementing our own Result type?

I'm down for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants