2015-07-02 2:49 GMT+02:00 Niall Douglas
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