DMD 0.148 release

Don Clugston dac at nospam.com.au
Tue Feb 28 06:21:45 PST 2006


Oskar Linde wrote:
> Tom skrev:
>> In article <du002m$2pnp$1 at digitaldaemon.com>, Ivan Senji says...
>>> Walter Bright wrote:
>>>> "Ivan Senji" <ivan.senji_REMOVE_ at _THIS__gmail.com> wrote in message
>>>>> Walter Bright wrote:
>>
>>> The problem in all these bool wars so far is I never saw an argument 
>>> that would be against true booleans (while(BooleanExpression) and all 
>>> that...).
>>
>> Yes, PLEASE, WHY?? Just ONE argument against pure bools, only one and 
>> I shut my
>> mouth forever!
>>
>> Tom;
> 
> Does pure booleans necessarily mean that other types could not be 
> implicitly convertible to bool? I would love "pure" booleans (not a 
> numeric type, not allowed in arithmetic operations), but I would hate to 
> have to write:
> 
> if (a !is null || b !is null)

I agree. I think implicit bool in conditionals is important,
but in assignments its almost always a bug.

eg
bool b=false;
b++;  // either this is hiding a bug, or it's a really confusing way of 
expressing what you want.

In a conditional, there's an implicit "!is null" at the end of every 
expression. That's why || is not the same as |.
This is not the same as implicit conversion from int to bool.
And bool-> int is a particularly troublesome conversion.

bool b;
int x = b;
This IS a mistake that I often make (eg, I typed 'b' when it should have 
been 'c').

Seems to me, that the useful cases Walter keeps talking about (and which 
I use all the time) can be accommodated, while still catching the sloppy 
thinking and type mismatch bugs where you get genuine benefit from pure 
bools.



More information about the Digitalmars-d-announce mailing list