DMD 0.148 release

Wang Zhen nehzgnaw at gmail.com
Sun Feb 26 07:43:56 PST 2006


Derek Parnell wrote:
> On Sun, 26 Feb 2006 17:29:03 +1100, Wang Zhen <nehzgnaw at gmail.com> 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,
> 
> 
> That's okay.
> 
>> 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;"?
> 
> 
> The short answer is that booleans are not numbers. They represent truth  
> and falsehood.
> 
>> Can't we simply treat zero as false and non-zero as true as we C  
>> programmers always do?
> 
> 
> *We* are not C programmers ;-) *We* have grown up from that baby-talk ;-)
> 
> Zero is frequently used to implement the concept of falsehood and 
> likewise  non-zero for truth, however the semantics of integers is not 
> the same as  the semantics of booleans. But because many C programers 
> are just *so*  used to thinking this way they have become to believe 
> that zero *is*  falsehood rather than just a number chosen to implement 
> the concept.

32-bit int is frequently used to implement the concept of integers, but 
they are semantically different. So what? Be a language purist and 
refuse to call int an integer until programmers can store arbitrary 
integers without having to worry about the implementation details?



> It is quite possible for a language to implement falsehood/truth is 
> ways  other than using integers but even if they do, the compiler can 
> still  ensure that the sematics are adhered to rather than continue 
> using integer  sematics.
> 
> The only thing I can see wrong with D's new boolean is that it still  
> pretends its a number. Why is this wrong? Because it can lead to coding  
> mistakes and abuse. Thus making maintenance more costly than it needed 
> to  be.

Pretending that bool is not a number can possibly lead to more confusion 
and misuse. Besides, many other features can also be abused in a 
practical language like D. Abandon them all just in case some 
unconscious programmer might make a mistake?


> Walter is still living in the C/C++ past with this concept, which is  
> strange seeing he has implemented so many progressive concepts in D.  
> Boolean as an integer is just retro.

I'm still not convinced why oldschool integer bools are inferior to 
newschool bools which may be abused by pointer tricks anyway.



More information about the Digitalmars-d-announce mailing list