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
Walter Bright wrote:
Currently, that can't be done. But it would be good to get it in for D2.
What for?
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
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
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
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?
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 :)
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));
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
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
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
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
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
13 matches
Mail list logo