On Friday, 29 March 2013 at 07:52:13 UTC, deadalnix wrote:
On Friday, 29 March 2013 at 07:48:39 UTC, TommiT wrote:
TDPL says:

"D defines a simple partial ordering relation for functions: if foo1 can be called with the parameter types of foo2, then foo1 ≤ foo2."

If you made the slightest change in the wording, you'd basically get the current C++ concepts-lite proposal in D:

"D defines a simple partial ordering relation for functions: if foo1 can be called with all the possible arguments that foo2 can be called with, then foo1 ≤ foo2."

At first, it almost sounds like the same statement, but now this would compile:

void fun(T)(T) if (T.sizeof >= 2) { }
void fun(T)(T) if (T.sizeof >= 4) { }

void main()
{
   fun(42); //calls the second one
}

I don't know if D would be better like that, but I just wanted point out how close the spec is to saying that.

That sound unimplementable, sorry.

I think we have different interpretations of what it means when function is callable. I think that foo is callable with int argument:

void foo(T)(T x)
{
    x("asdf");
}

void main()
{
    int n;
    foo(n); // the function call is made
}

It's just that there's a bug in foo's implementation that fails to compile, but the call to foo is yet made, i.e. foo is callable with an int argument.

Reply via email to