Feedback on Átila's Vision for D
Paul Backus
snarwin at gmail.com
Wed Oct 16 15:39:16 UTC 2019
On Wednesday, 16 October 2019 at 15:02:25 UTC, Sebastiaan Koppe
wrote:
> But I wouldn't go as far as actually evaluating them, just look
> at the symbols.
>
> That would probably result in A || B > B regardless of whether
> A is false or not. But then again why would you write such
> overloads?
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.
> 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.
More information about the Digitalmars-d
mailing list