Tristate - wanna?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Oct 31 10:10:35 PDT 2013
On 10/31/13 2:35 AM, Lionello Lunesu wrote:
> On 10/26/13, 17:42, Andrei Alexandrescu wrote:
>> unittest
>> {
>> Tristate a;
>> assert(a == Tristate.no);
>
> Why not have '0' map to unknown? Seems to more useful, like float.nan
> and the like.
So logical operations are closer to the built-in Boolean ones, and
conversion from bool is simple. If there's no such advantage, 0 should
be the most frequent value (comparisons against 0 are smallest and fastest).
One possibility is to make the initial value unknown by default (which
is a great idea).
I'll post shortly an update to Ternary (better name) along with
additions to std.allocator.
Andrei
More information about the Digitalmars-d
mailing list