PragmaTwice commented on code in PR #1032:
URL: 
https://github.com/apache/incubator-kvrocks/pull/1032#discussion_r1004108462


##########
src/common/status.h:
##########
@@ -285,3 +282,10 @@ struct StatusOr {
   template <typename>
   friend struct StatusOr;
 };
+
+#define GET_OR_RET(...)                                         \
+  ({                                                            \
+    auto&& status = (__VA_ARGS__);                              \
+    if (!status) return std::forward<decltype(status)>(status); \
+    std::forward<decltype(status)>(status);                     \
+  }).GetValue()

Review Comment:
   > For value combination, we may implement or use a result type with 
map/flatmap, or possibly use technology described [here 
(coroutine_monad)](https://github.com/toby-allsopp/coroutine_monad).
   
   C++17 does not have coroutine, and the technology used in the 
`coroutine_monad` repo is far more tricky than this macro.
   
   > It won't increase too much code.
   There are huge difference between expression and statement, e.g.
   ```c++
   auto x = h(GET_OR_RET(f(GET_OR_RET(g()))));
   ```
   Can you remove `GET_OR_RET` and still keep simple?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to