DMD 0.148 release

Derek Parnell derek at psych.ward
Sat Feb 25 23:37:43 PST 2006


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.

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.

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.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d-announce mailing list