On Tue, 30 Apr 2013 10:43:01 -0700, Rob T <[email protected]> wrote:

On Tuesday, 30 April 2013 at 14:47:14 UTC, Steven Schveighoffer wrote:

Yes, just like it's better matching to long than string.

-Steve

More precise language is to state that there is no "better match" and long should simply not ever match with bool because long is not the same thing as bool, ie, bool should not be seen as an integral type because it clearly isn't because it does not behave like one and has a completely different purpose in the language otherwise there'd be no need for a bool to have special differences that the other integrals do not have.

How do we get the problem fixed? The sooner it is done the better, otherwise we'll be forever stuck with subtle bugs and D programmers complaining about it for the rest of eternity.

1. bool doesn't match to 1 or 0.
2. cast(bool)0 -> false
3. cast(bool)(anything but 0) -> true
4. true -> (implicit cast) 1
5. false -> (implicit cast) 0.

Then all that is left is to change any place where 1 or 0 implicitly casts to true or false to true and false.

The one casualty is any code that passes 1 or 0 to a function overloaded with long, short, or byte (or unsigned versions), and bool, will now silently switch to calling the integral version. I would posit that this is extremely rare.

-Steve

Reply via email to