Deprecate implicit `int` to `bool` conversion for integer literals
Dmitry Olshansky
dmitry.olsh at gmail.com
Sun Nov 12 13:34:50 UTC 2017
On Saturday, 11 November 2017 at 14:54:42 UTC, Jonathan M Davis
wrote:
> On Saturday, November 11, 2017 13:40:23 Michael V. Franklin via
> Digitalmars- d wrote:
>> What's the official word on this:
>> https://github.com/dlang/dmd/pull/6404
>>
>> Does it need a DIP?
>>
>> If I revive it will it go anywhere?
>>
>> What needs to be done to move it forward?
>
> It probably needs a DIP, since it's a language change, and
> based on what Walter has said in the past about this topic, I
> don't know how convincible he his. I think that most everyone
> else thought that it was terrible when code like this
>
> auto foo(bool) {...}
> auto foo(long) {...}
>
> foo(1);
>
> ends up with the bool overload being called, but Walter's
> answer was just to add an int overload if you didn't want 1 to
> call the bool overload.
Yeah, this is bad.
However, I’d hate to rewrite things like:
if (a & (flag1 | flag2))
to
if ((a & (flag1 | flag2)) != 0)
When the first is quite obvious.
More information about the Digitalmars-d
mailing list