Boost logo

Boost :

Subject: Re: [boost] [outcome] Ternary logic -- need an example
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-05-15 15:57:02


>> This argument can be generalised into the argument in favour of ternary
>> logics over binary logics. Sure, 90% of the time binary logics are
>> sufficient, but binary is a subset of ternary. And *you don't have to
>> use* the "other" state in a ternary logic just because it's there. Just
>> don't use it, so long as its implementation signals its unintentional
>> usage with a very loud bang, it's a safe design.
>>
>> (There is an argument that Outcome's "very loud bang" isn't loud enough.
>> I'd be pleased to hear feedback on that)
>
> Niall, you mention "ternary logic" here, and I guess it has to do with
> 'module' `tribool` exposed by Outcome library. But I do not believe I have
> seen in the documentation (I mean the tutorial section) how I am supposed
> to use it, and how it improves my programs. Or I might have just missed it.
> Could you give me an example?

It doesn't have much to do with tribool. outcome<T> and result<T>
deliberately take a three state based design with an explicit choice of
ternary instead of binary state. The original motivation was actually
for the basic_monad based, since removed, non-allocating future-promise
implementation where we needed a third state to indicate "pending", but
it turned out to be very useful in itself for simplifying usage,
eliminating writing boilerplate, and acting as an out-of-band signalling
mechanism.

The debate over ternary vs binary is long standing since the very
beginnings of computer science. This past C++ Now talk by the review
manager does a far better job of explaining than I could:
https://www.youtube.com/watch?v=gLJrOTFw6J0

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk