Boost logo

Boost :

Subject: Re: [boost] Ternary logic programming (was: Re: [variant] Maintainer)
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2015-07-02 04:40:47


2015-07-02 2:49 GMT+02:00 Niall Douglas <s_sourceforge_at_[hidden]>:

> On 1 Jul 2015 at 15:53, charleyb123 . wrote:
>
> > Under an alternative model, the common construct would be something like:
> >
> > void foo(...) {
> > return switch_(...) {
> > ...
> > }
> > }
> >
> > ... and you manage your true/false/unknown cases explicitly. Works great
> > for asynchronous and distributed, and for interfacing-with-hardware.
>
> That's exactly what Rust does. In fact, you'll find yourself either
> writing match x { patterns ... } or using monadic programming. A lot,
> because there is little other choice.
>
> Out of interest, what do you think of my free function ternary logic
> programming:
>
> tribool t;
> if(true_(t)) { /* true */ }
> else if(false_(t)) { /* false */ }
> else if(unknown(t)) { /* other state */ }
>
> Nobody here seemed to like it. I am looking for something the average
> programmer will notice immediately and not accidentally assume it's
> boolen logic going on here.

Hi Niall,
Because I cannot see the direct connection between the three-state monad
you are exploring and a ternary logic (like in Boost.Tribool), I might be
missing something obvious, but why do you insist on calling the states
"true" and "false"? I know why Boost.Tribool does it: because it provides
operators || and && that intuitively implement "true", "false" and "I do
not know" concepts.

In your monad application, I have never seen operators || or && mentioned,
so there seems to be no reason to adapt names "true" and "false" for the
three states. You might as well call them "A", "B" or "C", or to more
closely reflect your application: "value", "failure", "internal_error".

Am I missing something?

regards,
&rzej


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