PragmaTwice commented on PR #768:
URL: 
https://github.com/apache/incubator-kvrocks/pull/768#issuecomment-1210159380

   Hi @ShooterIT, your understanding is generally correct. I'm still holding on 
to the hope that we'll be able to merge this PR, which I state below on various 
fronts.
   
   First, the original error handling method has several flaws:
   - the pointer passed in to store the result is readable, C++ doesn't have 
any flag to indicate that a pointer is write-only: this causes semantic 
confusion, in fact, we don't need the value the pointer is currently pointing 
to, this value is garbage when the result is not written;
   - the pointer passed in to store the result points to an already constructed 
object, which is usually default-constructed: this prevents us from 
constructing an object after processing (probably not via the default 
constructor), which It's a very popular way of doing things in C++.
   - we cannot use `auto` to deduce the output type because we have to 
construct it before calling the function.
   
   Second, `StatusOr` is designed to be very intuitive. This type has two 
states, one in which it stores a value representing the result, and one in 
which it stores an error (including an error code and error message). I always 
feel that `StatusOr` will be easier to use than the current form, and we can 
more intuitively express what we want to do.
   
   Lastly, I have no current plans to replace the parts of the current project 
that use `Status`, and I've even modified `Status` in this PR to make better 
use of move semantics in certain situation. Anyone can continue to use the 
previous form for error handling, it's just that I'll use it to make it easier 
to build some command parsing related functions.


-- 
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