[Issue 1528] [tdpl] overloading template and non-template functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 15 16:51:40 PDT 2013


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



--- Comment #32 from Kenji Hara <k.hara.pg at gmail.com> 2013-03-15 16:51:36 PDT ---
(In reply to comment #31)
> (In reply to comment #30)
> > ...
> > Parameter deduction is less specialized than matching to explicitly
> > specialized type parameter.
> > ...
> 
> It's not less specialized than a normal function call without type parameters.
> A type parameter should match a type argument exactly.
> 
> Specialization mustn't be confused with the matching level -- it should be
> checked in a second step, as is done for functions.
> 
> Why?: Specialization is a partial order, while the matching levels form a full
> order. There is no way to correctly implement specialization only by abusing
> matching levels.
> 
> (At the very least, the logic for template specialization should not interfere
> with template vs. function overloading!)

I talked the expected behavior by using the words used in dmd implementation.
Yes, MATCH(exact|const|convert|nomatch) might not be the best word to talk
language specification. But it is not a true problem.

Essentially the thing I talking is:

void foo(int) {}       // 1
void foo(T:int)(T) {}  // 2
void foo(T)(T) {}      // 3
foo(1);

Non template function (1) is specialized _as same as_ explicitly specialized
template function (2). Then, normally deduced template function is less
specialized than (1) and (2).

My patch represents the specialization order for IFTI by the pair of MATCH
value. And, (3) is represented by MATCHconvert / MATCHexact internally.

Do not confuse internal representation and expected language
specification/behavior.

-- 
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