[Issue 2025] Inconsistent rules for instantiating templates with a tuple parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 1 05:42:22 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=2025



--- Comment #11 from yebblies <yebblies at gmail.com> 2012-02-02 00:42:20 EST ---
(In reply to comment #10)
> So MATCHexact means "the pattern can be matched only by this exact set of
> arguments", and MATCHconvert means "this is one of various sets of arguments
> that can match this pattern".
> 

No, MATCHconvert means 'match with implicit conversions'.  These are the same
match levels used for normal function argument matching.

> But then, surely, it would be rejecting the instantiation as ambiguous, not
> picking the (A...) overload.
> 

Actually, (A...) is an alias parameter so it comes up as MATCHexact.  (There is
a bug report about this somewhere).  Otherwise you would get an ambiguity
error.  This is not what should be happening, non-variadic templates should be
preferred over variadic ones.

> Really, it's a fundamental flaw in the compiler logic whereby it conflates two
> essentially orthogonal concepts: exactness and specialisation.
> 
> A correct template instantiation algorithm would:
> - see which template patterns match the instantiation exactly
> - if none, see which template patterns match with implicit conversions
> - of all the matches, determine which is most specialised

It's not that simple when you take multiple parameters, overloads, mixing
explicit template parameters and deduced ones, etc

The ordering (exact match, const match, convert match, deduced match, variadic
match, alias match, specialized match, etc) is complicated and the match system
needs a redesign to cope with it.  Expanding the current match system will not
necessarily solve the problem, as the different levels interact in weird ways. 
This is probably what will end up happening if a better solution is not found.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list