Bools reloaded

Ivan Senji ivan.senji_REMOVE_ at _THIS__gmail.com
Fri Mar 3 11:39:06 PST 2006


Oskar Linde wrote:
> Ivan Senji wrote:
> 
>> Don Clugston wrote:
>>
>>> Sorry, that's still not clear.
>>> Bruno is right, terms like "pure bools" or "purist bools" are vague, 
>>> you can't expect everyone to know what you mean.
>>>
>>> For example: do you want "&" to be legal for bool types, or just "&&"?
>>
>>
>> Just &&.
> 
> 
> Why? Ever heard of boolean algebra? 

Ever heard of logic operators && and ||? That is what they are for.

> Why should &,|,^,~ not be defined 
> and allowed for bool? It would be problematic and inconsistent not 
> having non-short-circuit operators for booleans.

I learned from xs0's reply that Java uses &,| for non-short-circuit 
evaluation when arguments are of type bool. As D doesn't have a bool in 
the Java meaning I don't think making & anything but bitwise operator 
makes sense.

> 
>>> (they mean very different things for integers). "&" normally means 
>>> "bitwise and", but a pure bool doesn't have any bits.
>>> Is it legal to cast from a bool to some other type?
>>
>>
>> I'm not against casting but implicit conversions are bad.
> 
> 
> Do you mean that all implicit conversions are bad? Are the integer 
> promotion rules bad?

Ofcourse not. But with bools yes.

Do you think:
bool b = 5; would be a good thing?

int x = b/3; would be a good thing?





More information about the Digitalmars-d mailing list