Shouldn't bool be initialized to 0xFF ?

nobody nobody at mailinator.com
Fri Aug 18 02:35:34 PDT 2006


Lionello Lunesu wrote:
>>> This I don't get. How's having a default of false better than having 
>>> a default of true?
>>
>> I can see why this might not be obvious if you do not much of a 
>> background with C style languages. In most C style languages (C, C++, 
>> Java and D) pretty much anything is 'true' if it is non-zero because 
>> 'truth' can be determined by simply testing for inequality with the 
>> constant 0. Thus the only default initializer which works the same for 
>> "pretty much anything" is a zero bit pattern. I think it is impossible 
>> to stress enough how ingrained this reality becomes. The best example 
>> of exactly how ingrained it is would be my implicit assumption that 
>> anyone else would see the folly of a default value evaluating true.
> 
> I'm coming from C/C++ myself. In C/C++ you always have to initialize 
> your variables, so the language has no preference for either true or 
> false. Are you saying that you name your variables and flags such that 
> "false" is the default? That seems like strange to me. For program 
> options, for example, it would mean that you choose names that are "not 
> true" (options that are not selected) as the default. Seems exactly the 
> wrong way around. Not to mention the fact that you can end up with 
> variables called "NotShowingSizes = false;" and "if (!NotShowingSizes) 
> ...."  :S

   HideSizes (gerunds don't work for me here) : )

> 
>>>     bit is gone, and bool is similar to C++'s bool. bool.sizeof==1, 
>>> and a bool[32] needs 32 bytes.
>>
>> Do you know why it was eliminated? Or perhaps have some idea of when? 
>> Or even a general spot to start looking in posts to find out why myself?
> 
> I think because of the problems with bit[] and the fact that you could 
> not take a pointer to it. Check the change log 
> http://www.digitalmars.com/d/changelog.html (I would check it for you, 
> but it seems I can't access it at the moment?)
> 

Thanks for the suggestion. I will probably have to kill my thunderbird NG 
subscription and try loading up 5,000 archived messages to see if that gets me 
back to the reasoning behind the Feb changes.

http://www.digitalmars.com/d/changelog.html
What's New for D 0.148
Feb 25, 2006

New/Changed Features
  ...
# Removed bit basic type.
# Added bool basic type.
# Added BitArray.



More information about the Digitalmars-d mailing list