implicit cast and overload priority

Paul Backus snarwin at gmail.com
Sat Feb 15 20:12:43 UTC 2025


On Saturday, 15 February 2025 at 15:40:51 UTC, Dom DiSc wrote:
> On Friday, 14 February 2025 at 15:58:26 UTC, Paul Backus wrote:
>> Oops--it turns out both overloads are equally specialized!
>
> This is what I want to be fixed. For a human it is obvious 
> which of the two is a better match. Lets add a rule so that the 
> compiler can also see it!

The problem with this approach is that, if you keep adding more 
and more rules, you eventually end up with so many that no human 
can remember them all, and code becomes much harder to understand.

In C++, for example, overload resolution is extremely 
complicated, because they added a bunch of rules to make these 
kinds of "obvious" examples work:

https://en.cppreference.com/w/cpp/language/overload_resolution


More information about the Digitalmars-d-learn mailing list