On 26 Jan 2016 at 0:16, Michael Marcin wrote:
Some months ago there was a lot of discussion regarding Rust style return values for non-exceptional error handling.
Mine was one of many discussed. Its current name is Outcome.
Did anything ever come of this?
Yes, Outcome continues to mature as it is being used to write AFIO v2. The non-futurey bits are quite mature by now and have seen very extensive usage. The futurey bits aren't being used in the AFIO v2 rewrite yet, and so haven't had the same quantity of very fine level tweaking. If I do say so myself, it is *spectacularly* well suited to this use case, producing seriously high quality assembler output. I am very, very pleased with it.
Is there a useable library?
https://github.com/ned14/boost.outcome It requires VS2015 Update 1 or newer, or any C++ 14 compiler. Some example AFIO v2 code using it: https://github.com/BoostGSoC13/boost.afio/blob/master/fs_probe/include /handle.hpp https://github.com/BoostGSoC13/boost.afio/blob/master/fs_probe/include /detail/impl/windows/handle.ipp As you'll see, the enormous win is that almost every function apart from constructors is now noexcept. That causes the compiler to do a very good job indeed of inlining and eliminating code from the assembler output, plus static analysis tools spot when you forget to properly handle an errored return because it'll try throwing in a noexcept function. I expect AFIO v2 to have an undetectable overhead relative to syscalls, even no op syscalls. Two big items remain todo for Outcome: 1. I want to write a clang-tidy extension which rewrites any outcome returning function to be noexcept unless commented otherwise. This prevents one forgetting to add noexcept. 2. I want another clang-tidy extension to mark up outcome returning functions with the compiler-specific markup to complain if you forget to do something with the returned value. Right now outcomes have the same problem as C error returns, one can forget to handle them altogether. I also strongly emphasise that nothing in Outcome is fixed, things may yet change. Outcome is not in the Boost review queue, nor may never be. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/