Shouldn't bool be initialized to 0xFF ?

Max Samuha maxter at i.com.ua
Wed Aug 16 07:15:22 PDT 2006


On Wed, 16 Aug 2006 14:45:57 +0300, Lionello Lunesu
<lio at lunesu.remove.com> wrote:

>Frank Benoit wrote:
>> That make only problems, nothing more.
>> I don't like this suggestion.
>> 
>> VOTE--;
>
>Frankly, it's not about liking or not. This suggestion is about 
>consistency. I think the same reasons for the 0xFF initializer for 
>char/wchar/dchar also apply to bool.
>
>L.


For consistency, I'd personally prefer what they call 'nullable value
types' in C#. If you want to distinguish between initialized and null
variables of value type just add ? to the type identifier. I know that
such types require more memory to store additional information about
the null state but the approach is much nicer and consistent than
special value hacks (imho).  

bool? b = null;
if (b == null){}

Oops, i forget that D is not C#:) 




More information about the Digitalmars-d mailing list