DMD 0.148 release

Georg Wrede georg at nospam.org
Sun Feb 26 16:10:29 PST 2006


Ivan Senji wrote:
> Georg Wrede wrote:
> 
>> Ivan Senji wrote:
>>
>>> Georg Wrede wrote:
>>>
>>>> Derek Parnell wrote:
>>>>
>>>>> On Mon, 27 Feb 2006 06:05:13 +1100, Georg Wrede <georg at nospam.org> 
>>>>> wrote:
>>>>
>>>>
>>>>
>>>>>> We've all had our fights with C, C++, and other related languages. 
>>>>>> But  honestly, how many of us can confess to having problems with 
>>>>>> logical  values?
>>>>>
>>>>>
>>>>> Me.
>>>>>
>>>>>> And if someone here has such problems, I suggest switching to VB.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> I am also a VB coder and I'm not a language bigot.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Oh. I'm sorry. I'll try not to mention VB in the future.
>>>>
>>>> ---
>>>>
>>>> I think we've gotten it backwards here, so let's turn the table:
>>>>
>>>> Can you give some example code and use cases where we absolutely 
>>>> need your kind of booleans?
> 
> 
> Could it be that I missunderstood you? By your kind of booleans did you 
> mean the true non-integer booleans? If so, that is what the example dow 
> there is for: showing why we need real bools.
> 
> And if I did missunderstand something I apologize (it's late).

No problem. The way this whole thread is going, half the time everybody 
is clueless. :-)

>>> Ok, I'll give an example of that right after you give an example of 
>>> why and where this is needed/good/(not extremly bad):
>>>
>>>   bool a, b, c;
>>>   a = true;
>>>   b = true;
>>>   c = true;
>>>
>>>   a = b+c; // true + true is what?
>>
>>
>> That's why we do want to have booleans. The whole point of having 
>> booleans is to not do that by mistake.
> 
> Are you now saying you want real booleans that are not ints?

On the inside they should be ints. Mostly for efficiency reasons, but 
also for established coding conventions.

But on the outside, they should not be compatible with ints.

In other words, doing

bool foo = 55 && 5000;

should be legal, and it should store the 'true value' (that'd be a 1) 
into foo.

But doing:

bool a = 1;  // legal, but poor coding
bool b = 0;  // likewise
whateverType bar = a + b;  // should produce a compiler error
                            // since addition of bools is illegal

>>>   if(5) //if 5 what? what does that mean (except nothing)?
>>
>> Ever seen this:
>>
>> while(1)
> 
> I sure did, and it scares the hell out of me :)
> 
>> written in source code?
>>
>> Or this:
>>
>> c = getCharacter(inf);
>> if (c) { /* whatever */ }
> 
> ...even worse :)
>>
>> Oh, by the way, just checked how many times 'while(1)' appears in 
>> src/phobos/std:
>>
>> grep "while *( *1 *)" *.d |wc
>>
>> answer: 16 times.
> 
> Scary.
> 



>> Now, let's see your promised example.
> 
> My example was supposed to be an example for:
> a) real bools being needed
> b) int bool being bad

I'm still waiting.





More information about the Digitalmars-d-announce mailing list