Why does partial ordering of overloaded functions not take return type into account?

Chris Wright via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 20 09:05:51 PST 2016


On Sat, 20 Feb 2016 15:47:27 +0000, Jeremy DeHaan wrote:

> If there are multiple overloads that have the same number of parameters,
> a very simple addition to the rules of function overloading would be
> "does it compile?" If only one overload compiles, use it. If more than
> one compile, there is ambiguity and its an error.

So you've got a function with three overloads based solely on return 
type. You use that overload set once in a function, so the compiler has 
to try to compile that function three times. That works.

Now you use that overload set twice. The compiler has to compile the 
function nine times.

You use it ten times. Now the compiler needs to make 59,049 passes for 
that one function.


More information about the Digitalmars-d-learn mailing list