Deprecate implicit `int` to `bool` conversion for integer literals

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Nov 11 14:54:42 UTC 2017


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. He may
be more amenable to deprecating the implicit conversion now than he was
then, but it's the sort of thing where I would expect there to have to be a
DIP rather than it simply being done in a PR, since it's a definite semantic
change and not one that Walter previously agreed should be made. I have no
idea what Andrei's opinion on the topic is.

- Jonathan M Davis



More information about the Digitalmars-d mailing list