DIP 1015--Deprecation of Implicit Conversion of Int. & Char. Literals to bool--Formal Assement
Isaac S.
spam-no-reply-isaac at outlook.com
Tue Nov 13 23:50:52 UTC 2018
On Monday, 12 November 2018 at 22:07:39 UTC, Walter Bright wrote:
> int f(short s) { return 1; }
> int f(int i) { return 2; }
>
> enum : int { a = 0 }
> enum A : int { a = 0 }
>
> pragma (msg, f(a)); // calls f(int)
> pragma (msg, f(A.a)); // calls f(short)
>
> *snip*
>
> So f(short) is selected, because the "Most Specialized"
> function is selected when there is an ambiguous match.
>
> Note: the "most specialized" partial ordering rules are
> independent of the arguments being passed.
Walter, this still doesn't change the fact any _reasonable_
programmer would expect foo(A.a) to, in a way, convert to
foo(int(0)) because that keeps the type information rather than
ignoring the type information completely and just putting the
literal value in like it was foo(0).
Honestly, while I (and most others in the community) wanted
DIP1015, I'm not going to sweat it (even given the illogical
reason for refusing it), but marking issue 10560 as "correct
behavior" is asinine and ignorant.
More information about the Digitalmars-d-announce
mailing list