bool <=> int. WTF. (DIP0015)

wjoe invalid at example.com
Fri Jul 5 16:29:56 UTC 2019


On Thursday, 4 July 2019 at 16:31:11 UTC, Patrick Schluter wrote:
> On Thursday, 4 July 2019 at 15:30:59 UTC, wjoe wrote:
> [snip good arguments]
>
>> or even better - the C way. Is it 0, or else...
>> This is completely predictable unlike the bool b = void; can 
>> be true and false at the same time.
>
> that's the issue. D's bool type follows exactly C (C has bool 
> since C99) and C++ way. bool b; will behave exactly like your 
> bool b = void;

I wouldn't know. I've used C before that came to pass. But from 
what I read online it doesn't behave exactly the same way. Like 
not at all.

But for clarification. What I was referring to was using an 
integer in place of a Boolean.

>>
>> The whole point of a Boolean data type is that it's something 
>> in its own right and decoupled from the implementation. 
>> Otherwise it's a redundancy.
>>
>> But then, IMHO, Boolean is almost always best to be replaced 
>> by something more expressive like std.typecons.Flag
>>
>> On that note if there's something that can be removed from the 
>> D language, it's bool.
>
> Nope.

Yes.


More information about the Digitalmars-d mailing list