|
Boost : |
Subject: Re: [boost] [variant] Maintainer
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2015-06-28 09:38:08
Le 28/06/15 15:15, Niall Douglas a écrit :
> On 28 Jun 2015 at 10:38, Vicente J. Botet Escriba wrote:
>
>> The current C++ proposal design has a hidden error state that IMO is
>> viral and should be fixed. The problem is that with the current language
>> there is no know implementation without using extra memory (as
>> boost::variant does). I would like to see the language modified so that
>> the boost::variant original implementation [1] is well-formed. This
>> implementation would still be less efficient than an possible empty
>> variant that mix empty and error, but the guaranties would be different.
> I think adding ternary logic support to the language would make
> solving this sort of problem much more elegant. Charley Bay did a
> good talk "Your CPU is Binary" at C++ Now which convinced me to add
> tribool support to lightweight monad + future such that:
>
> Empty => False
> Value => True
> Errored/Excepted => Indeterminate
>
> Ternary logic then has the truth tables from
> https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_log
> ics.
>
> The extension to the C++ language, if I understood what was proposed
> by Charley, is minimal:
>
> variant<...> v;
> tribool t(v); // from explicit operator tribool()
> if(t) { /* has value */ }
> else if(!t) { /* is empty */ }
> else { /* is errored */ } // Failure to provide this branch is a
> compiler error
Sorry Nial, but I don't want to program like that.
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk