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

Steven Schveighoffer schveiguy at yahoo.com
Tue Nov 14 13:54:03 UTC 2017


On 11/14/17 8:32 AM, Andrei Alexandrescu wrote:
> On 11/14/17 8:20 AM, Nick Treleaven wrote:
>> On Sunday, 12 November 2017 at 16:57:05 UTC, Andrei Alexandrescu wrote:
>>> The overload being called depends on (a) whether a - b can be 
>>> computed during compilation or not, and (b) the actual value of a - 
>>> b. Clearly a big problem for modular code. This is the smoking gun 
>>> motivating the DIP.
>>
>> An very similar problem exists for int and char overloads:
>>
>> alias foo = (char c) => 1;
>> alias foo = (int i) => 4;
>>
>> enum int e = 7;
>> static assert(foo(e) == 4); // fails
> 
> Thanks. Addressing this should be part of the DIP as well. -- Andrei

IMO, no character types should implicitly convert from integer types. In 
fact, character types shouldn't convert from ANYTHING (even other 
character types). We have so many problems with this.

-Steve


More information about the Digitalmars-d mailing list