On Sat, 22 Oct 2011 05:42:10 -0400, Manu <turkey...@gmail.com> wrote:
Sure, and hijacking is bound to happen under your proposal, no?
How would it be detected?
On 22 October 2011 06:51, Robert Jacques <sandf...@jhu.edu> wrote:
On Fri, 21 Oct 2011 19:04:43 -0400, Manu <turkey...@gmail.com> wrote:
It would still allow function hijacking.
void func(double v); exists...
func(2);
then someone comes along and adds func(float v); .. It will now hijack the
call.
That's what you mean right?
Hijacking is what happends when someone adds func(float v); _in another
module_. And that hijack would/should still be detected, etc. like any
other hijack.
Manu, I'm not sure you understand how function hijack detection works today.
Let us say you have three modules
module a;
float func(float v) { return v; }
module b;
double func(double v) { return v; }
module c;
int func(int v) { return v*v; }
which all define a func method. Now, if you
import a;
import b;
void main(string[] args) {
assert(func(1.0f) == 1.0f); // Error
}
you'll get a function hijacking error because func(1.0f) matches func(float)
and func(double). However, if you instead:
import a;
import c;
void main(string[] args) {
assert(func(1.0f) == 1.0f); // Error
}
you won't get an error, because func(1.0f) doesn't match func(int).
In short, the best overload is only selected _after_ the module name has been
resolved. The proposal of myself and others only affects which overload is the
best match; it has no possible effect on function hijacking.