Feedback on Átila's Vision for D
Sebastiaan Koppe
mail at skoppe.eu
Wed Oct 16 18:15:45 UTC 2019
On Wednesday, 16 October 2019 at 15:39:16 UTC, Paul Backus wrote:
> Consider the following example:
>
> enum isA(T) = __traits(compiles, ...);
> enum isB(T) = __traits(compiles, ...);
> enum isC(T) = __traits(compiles, ...);
>
> enum isAB(T) = isA!T && isB!T;
> enum isAC(T) = isA!T && isC!T;
> enum isBC(T) = isB!T && isC!T;
>
> auto fun(T)(T t) if (isAB!T) { ... }
> auto fun(T)(T t) if (isAC!T && isBC!T) { ... }
>
> C++'s partial ordering for concepts is able to correctly
> determine that the second overload is more specialized than the
> first. Your proposed solution that only examines the symbols is
> not.
Yes it would. But maybe I am not explaining myself well enough.
If you were to substitute the symbols and literally count the
boolean operators, the fun's would get 1 and 3 respectively. That
is what I meant with ast+lookup. Sorry for being so brief.
This is a very alpha idea and far from a solution, it is just
that I don't believe it can't be done.
>> Might be a nice project to try to solve with dmd as a library
>> or libdparse, to see if it is more than just an idea.
>
> Overload resolution is handled entirely inside the compiler, so
> an external tool won't help.
Of course, I understand, but it would suffice as a way to
validate the idea. Just give it a bunch of code and it would
output the ordering of function overloads with template
constraints. See it as a cheap way to validate an idea before
mucking in the compiler.
Anyway, I have already talked about it too much.
More information about the Digitalmars-d
mailing list