A Vision on Improved DMD Template Instantiation Diagonostics
via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jun 12 05:20:57 PDT 2015
After having seen Andrei's & Walter's talks on DConf 2015 it's
time reveal a dream of mine. It resolves around of feature that I
believe is one of the most important improvements that will
benefit aggregation of more *new* users to the D Community.
Namely a more clever DMD diagnostics when a template instantion
fails to match any template definition in the current scope.
For instance, if
f(a,b,c,d)
fails to match any of the overloads
f(a,b,c) if (PRED_1(a,b,c) && PRED_2(a,b,c))
f(a,b,c,d) if (PRED(a,b) && PRED(b,c) && PRED(c,d))
instead of saying
> Error: neither of these matched
> - f(a,b,c) if (PRED_1(a,b,c) && PRED_2(a,b,c))
> - f(a,b,c,d) if (PRED(a,b) && PRED(b,c) && PRED(c,d))
it should instead say
> Error: no template match to call of
> f(a,b,c,d)
> for neither
> - f(a,b,c) if (PRED_1(a,b,c) && PRED_2(a,b,c))
-------------
> because template restriction `PRED_2(a,b,c)` evaluate to
false
> - f(a,b,c,d) if (PRED(a,b) && PRED(b,c) && PRED(c,d))
---------
> because template restriction `PRED(b,c)` evaluated to
false
Eventhough this might be a bit tricky to get right and may break
lots of existing diagnostics (in DMD unittests), I'd say it's
definitiely worth effort. Such a feature would attract lots of
new users not used to D's advanced template restrictions. All
users, newbies aswell as experts, would be benefit from this
feature. I you DMD review guys are interested in getting this in
and helping me out on source code directions I'd be very happy to
start working on DMD PR for this.
Destroy.
More information about the Digitalmars-d
mailing list