Thu, 30 Jul 2009 14:09:21 -0700, Walter Bright wrote: > Currently, that can't be done. But it would be good to get it in for D2. > The question is, what rule to use? > > I suggest that: > > 1. if any functions match, then overload functions the usual way > > 2. if no functions match, then overload the function templates the usual way > > Or reverse the priority of the two. > > What do you think?
I think regular functions should go first. Let's take 4 functions for example: void foo(int); void foo(long); void foo(T)(T); void foo(T : int)(T); and call foo(5); If regular functions go first, we can order ours by match quality: void foo(int); <= best void foo(long); void foo(T : int)(T); void foo(T)(T); <= worst That's OK, the worst match is the least specialized template. But if we consider templates first: void foo(T : int)(T); <= best void foo(T)(T); void foo(int); void foo(long); <= worst What I strongly dislike about this is that a generic, non-specialized foo(T)(T) effectively hides any non-templated and obviously more specialized regular functions. I think this simply won't work.
