Uh oh!
There was an error while loading. Please reload this page.
backport c++23 std::expected - #40
Conversation
lidavidm
left a comment
There was a problem hiding this comment.
I think we have to update NOTICE and/or LICENSE when vendoring code?
Uh oh!
There was an error while loading. Please reload this page.
e61834e to
b97169fCompareUh oh!
There was an error while loading. Please reload this page.
cc50d13 to
4bd3010CompareAfter studied [0], [1] and [2], I'm inclined to backport [0] to iceberg-cpp, the main reason is that [0] has exactly the same APIs as std::expected, [1] provide some extra member functions like `map` and `map_error`, [2] has different API names like `then` and `thenOrThrow`. We want users to use iceberg::expected the same way as std::expected, and we will replace iceberg::expected with std::expected when we decide to move to c++23 some day, by backporting [0], we can facilitate a smoother transition process. We discussed about `Exceptions vs Expected` in apache#14, while backporting [0], I had the feeling we shouldn't choose one over the other, we can use both approaches effectively. expected provide monadic operations like `and_then`, `transform`, `or_else`, `transform_error`, let us do method chaining, which is a good sign. [0] https://github.com/zeus-cpp/expected [1] https://github.com/TartanLlama/expected [2] https://github.com/facebook/folly/blob/main/folly/Expected.h [3] https://en.cppreference.com/w/cpp/utility/expected Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
1c4aed7 to
b80f036Comparedisable clang-tidy for backported std:expected since we don't want to diverge from upstream. Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
b80f036 to
0c6802bCompareSigned-off-by: Junwang Zhao <zhjwpku@gmail.com>
This reverts commit 2ae7f2d.
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
lidavidm
left a comment
There was a problem hiding this comment.
LGTM. IMO let's get moving on this.
BTW, we could consider writing a custom check to just enforce [[nodiscard]] on functions returning expected? https://clang.llvm.org/extra/clang-tidy/Contributing.html
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
zhjwpku
commented
Feb 4, 2025
Reasonable, will file an issue once this PR got merged. |
wgtmac
commented
Feb 5, 2025
Is it possible to check the macro __cpp_lib_expected and directly use |
pitrou
commented
Feb 5, 2025
That may lead to ABI issues. For example if iceberg-cpp is compiled using a C++20 compiler, and then an application links to it with C++23 enabled. Or the reverse. |
wgtmac
commented
Feb 5, 2025
Make sense. Thanks! |
zhjwpku
commented
Feb 6, 2025
wgtmac
commented
Feb 18, 2025
pitrou
commented
Feb 18, 2025
I'm surprised by the license header. Shouldn't we use the Apache license there and record the provenance elsewhere? |
zhjwpku
commented
Feb 19, 2025
Yes, that was the initial version. I adopted the ASF License and included the zeus-cpp License (MIT) in the NOTICE file. There is a line in the ASF License: I'm unsure if this is sufficient. @lidavidm suggested some references from Arrow, which led us to finalize the current version. |
lidavidm
commented
Feb 19, 2025
An Apache member corrected this in arrow-java by making sure vendored files had their original license header: apache/arrow-java#550 |
Fokko
commented
Feb 26, 2025
Thanks @zhjwpku for adding this, and the |
After studied [0], [1] and [2], I'm inclined to backport [0] to iceberg-cpp, the main reason is that [0] has exactly the same APIs as std::expected, [1] provide some extra member functions like
mapandmap_error, [2] has different API names likethenandthenOrThrow.We want users to use iceberg::expected the same way as std::expected, and we will replace iceberg::expected with std::expected when we decide to move to c++23 some day, by backporting [0], we can facilitate a smoother transition process.
We discussed about
Exceptions vs Expectedin #14, while backporting [0], I had the feeling we shouldn't choose one over the other, we can use both approaches effectively.expected provide monadic operations like
and_then,transform,or_else,transform_error, let us do method chaining, which is a good sign.[0] https://github.com/zeus-cpp/expected
[1] https://github.com/TartanLlama/expected
[2] https://github.com/facebook/folly/blob/main/folly/Expected.h
[3] https://en.cppreference.com/w/cpp/utility/expected