DMD 0.148 release

Charles noone at nowhere.com
Sun Feb 26 09:36:08 PST 2006


 > Can't we simply treat zero as false and non-zero as true as we C
 > programmers always do?

I agree, I still don't get what the 'true bool' fuss is about .

Wang Zhen wrote:
> Derek Parnell wrote:
> 
>> On Sun, 26 Feb 2006 12:54:15 +1100, Walter Bright  
>> <newshound at digitalmars.com> wrote:
>>
>>> Lots of new stuff, I added new threads for them in the digitalmars.D
>>> newsgroup.
>>>
>>
>> Well you almost got bool right <G> Everything except that it does 
>> implicit  conversion to int. That is just a cheap cop out for lazy 
>> coding, IMNSHO.
> 
> 
> Pardon my ignorance, but why does D need a primitive type for booleans 
> in the first place? What's wrong with "alias ubyte bool;" or "alias int 
> bool;"? Can't we simply treat zero as false and non-zero as true as we C 
> programmers always do?
> 
> 
>>
>> //--------------------
>> import std.stdio;
>>
>> void main()
>> {
>>   bool a;
>>   bool b;
>>   bool c;
>>   bool d;
>>   int e;
>>
>>   a = true;
>>   b = true;
>>   c = true;
>>   d = a + b + c;
>>   e = a + b + c; // In a decent implentation, this should have failed 
>> to  compile
>>   writefln("%s %s %s %s %s", a,b,c,d,e);
>>   writefln("%d %d %d %d %d", a,b,c,d,e); // And this might have been 
>> a  runtime error?
>>
>> }
>> //-------------------
> 
> 



More information about the Digitalmars-d-announce mailing list