overloading functions against function templates

2009-07-30 Thread Walter Bright
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

Re: overloading functions against function templates

2009-07-30 Thread grauzone
Walter Bright wrote: Currently, that can't be done. But it would be good to get it in for D2. What for?

Re: overloading functions against function templates

2009-07-30 Thread bearophile
Walter Bright: >Currently, that can't be done. But it would be good to get it in for D2.< I think someone has already asked for this feature, time ago :-) > The question is, what rule to use? > I suggest that: > 1. if any functions match, then overload functions the usual way > 2. if no function

Re: overloading functions against function templates

2009-07-30 Thread bearophile
grauzone: >What for?< Even if for every person that may ask for such feature, there are probably 30 persons that may ask for the "stacktrace hack" built-in in DMD, I presume such overload of functions against function templates is more fun to implement :-) DMD is probably fun-driven too, not ju

Re: overloading functions against function templates

2009-07-30 Thread BCS
Reply to Walter, 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 revers

Re: overloading functions against function templates

2009-07-30 Thread Lutger
My intuition would be that functions are more concrete than templates, and thus will be checked first. Will implicit conversions match the same way as exact type matches?

Re: overloading functions against function templates

2009-07-30 Thread Trass3r
bearophile schrieb: Even if for every person that may ask for such feature, there are probably 30 persons that may ask for the "stacktrace hack" built-in in DMD > That's true :)

Re: overloading functions against function templates

2009-07-30 Thread ponce
How would compete template specialization and matching functions ? like : double foo(double x) { return x * 2; } double foo(T)(T x) { return x * 3; } double foo(T : double)(T x) { return x * 4; } writeln(foo(4.0));

Re: overloading functions against function templates

2009-07-31 Thread Michal Minich
bearophile wrote: > import std.stdio: writeln; > double foo(int x) { return x * 2; } > double foo(float x) { return x * 3; } double foo(T)(T x) { return x * 4; > } > double foo(T : double)(T x) { return x * 5; } void main() { > writeln(foo(10));// prints: > writeln(foo(10.5)); // prin

Re: overloading functions against function templates

2009-07-31 Thread Lars T. Kyllingstad
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? Yay! I've been waiting for this! :) I suggest that: 1. if any functions match, then overload functions the usual way 2. if no functions match, then overload the

Re: overloading functions against function templates

2009-07-31 Thread Sergey Gromov
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 over

Re: overloading functions against function templates

2009-07-31 Thread Jason House
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? My vote would be to use partial ordering [1] for consistency. I'm just not sure what that would mean in this situation :( [1] http://dobbscodetalk.com/index.ph

Re: overloading functions against function templates

2009-07-31 Thread BCS
Hello Lars, If you are going to allow ordinary and templated functions to overload against each other, there is a problem with IFTI that I think will become more visible. It's something I run into all the time: T sum(T)(T a, T b) { return a + b; } real x = 2.0; real y = sum(1.0, x); The abov