-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backport c++23 std::expected #40
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have to update NOTICE and/or LICENSE when vendoring code?
e61834e
to
b97169f
Compare
cc50d13
to
4bd3010
Compare
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 `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
b80f036
Compare
disable 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
0c6802b
Compare
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
This reverts commit 2ae7f2d.
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
Reasonable, will file an issue once this PR got merged. |
Is it possible to check the macro __cpp_lib_expected and directly use |
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. |
Make sense. Thanks! |
I'm surprised by the license header. Shouldn't we use the Apache license there and record the provenance elsewhere? |
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. |
An Apache member corrected this in arrow-java by making sure vendored files had their original license header: apache/arrow-java#550 |
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
map
andmap_error
, [2] has different API names likethen
andthenOrThrow
.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 #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