D almost has concepts (lite)
TommiT
tommitissari at hotmail.com
Fri Mar 29 00:48:38 PDT 2013
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.
More information about the Digitalmars-d
mailing list