BigInt bool assign

Timon Gehr timon.gehr at gmx.ch
Fri Dec 23 16:32:17 PST 2011


On 12/23/2011 11:34 PM, Jonathan M Davis wrote:
> On Friday, December 23, 2011 17:19:26 bearophile wrote:
>> Derek Parnell:
>>> I'm with Don on this one because a boolean and an integer are not the
>>> same concept, and even though many programming languages implement
>>> booleans using integers, it still doesn't make them the same thing.
>>
>> D doesn't implement booleans with integers, D has a boolean type. But D
>> allows bools to implicitly cast to ints/longs.
>
> I'd actually argue that that's a mistake. Implicitly converting an int to a
> bool is one thing - that's useful in conditional expressions - but converting
> from bool to int is something else entirely. I see no reason to expand that
> problem into BigInt. _int_ shouldn't have it, let alone BigInt.
>
> - Jonathan M Davis

A: "Um, so why does bool implicitly convert to int but not to BigInt?"
B: "Because the language's design contains an error. It is a huge 
_problem_. Therefore we decided to keep it inconsistent. If you 
re-parenthesise your expression however, your code will compile."
A: "Awesome!!"


More information about the Digitalmars-d mailing list