felipecrv commented on code in PR #33912:
URL: https://github.com/apache/arrow/pull/33912#discussion_r1091106649
##########
cpp/src/arrow/result.h:
##########
@@ -371,7 +371,7 @@ class [[nodiscard]] Result : public
util::EqualityComparable<Result<T>> {
if (ok()) {
return MoveValueUnsafe();
}
- return generate_alternative();
+ return std::forward<G>(generate_alternative)();
Review Comment:
Note that from the comment, `generate_alternative` is supposed to be a
factory not an actual `T` or parameters that can be forwarded to `T`'s
constructor. This is a way to avoid evaluating the parameter when `Result`
already contains something.
Functional Programming languages make this kind of lazy parameter
(call-by-name) very easy to declare. In Scalar this would be `alternative: =>
T` instead of `alternative: T`.
https://www.scala-lang.org/api/current/scala/Option.html#getOrElse[B%3E:A](default:=%3EB):B
--
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]