On Monday, 23 April 2018 at 14:22:13 UTC, Simen Kjærås wrote:
As with all things D, the only real spec is the compiler source code. :p :(

:p

Proving that two templates are equivalent is in general impossible, since any amount of wasted computation could be performed before the end result is returned, and inputs must be tested exhaustively for the proof to be valid. The fact that two templates give the same result in one special case does not mean that they are equivalent in the general case, and the compiler needs to care about the general case.

Ok, thats exactly the point. If you have functions

void foo() {}
void foo(int n) {}

There is no ambiguity which function will be chosen if it will be called.

If you have templates

// form 1
template Foo(int N) if (N & 1)    {} // A
template Foo(int N) if (!(N & 1)) {} // B

OR

// form 2
template foo(int N)
{
        static if(N & 1){} // A
        else{} // B
}

There is also no ambiguity which will be called.

However, getOverloads will behave differently.

This is not bad at all. But you have to admit, that while now, there is no way to distinguish form 1 and form 2, with the new getOverloads there will be. This seems strange to me, because there is no reason to distinguish form 1 and form 2. (Because the callable code, which will be generated is the same, I hope... ?)

So, in particular, I'm not against the feature. And if the equivalence between form 1 and form 2 is gone, so what. But I don't understand the reasoning why something which is now equal won't be equal any more later?

Reply via email to