1 matches bool, 2 matches long
Minas Mina
minas_mina1990 at hotmail.co.uk
Sun Apr 28 15:47:40 PDT 2013
On Sunday, 28 April 2013 at 22:40:33 UTC, Andrei Alexandrescu
wrote:
> On 4/28/13 5:41 PM, kenji hara wrote:
>> Yes, as Andrei mentioned, it is sometimes useful. But, at
>> least during
>> overload resolution, it must not occur.
>>
>> Kenji Hara
>
> Well the problem has other ramifications beyond bool. Consider:
>
> import std.stdio;
>
> int fun(short v1) { return 1; }
> int fun(long v1) { return 2; }
>
> void main(string[] args)
> {
> writeln(fun(10_000));
> writeln(fun(100_000));
> }
>
> This prints "1 2". So the behavior of bool in this case is
> consistent with the behavior of other integral types.
>
>
> Andrei
It's not entirely the same. You provided two overloads of
integral types. bool is not integral.
And yes, I personally don't like this either, but I could live
with it. Buy fun(1) calling the bool overload? It's ridiculous.
"Code that looks correct should be correct". fun(1) calling bool
overload sure looks and is correct.
More information about the Digitalmars-d
mailing list