D almost has concepts (lite)

deadalnix deadalnix at gmail.com
Fri Mar 29 00:52:12 PDT 2013


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.


More information about the Digitalmars-d mailing list