On 2/4/13 12:14 AM, Steven Schveighoffer wrote:
I wanted to put forth again a proposal I had for getting a delegate to
an overloaded function. Only because I think it's relevant to the latest
property debate.

When getting the address of a delegate, it's as simple as:

struct S
{
void foo(int x) {}
}

S s;
auto dg = &s.foo; // delegate obtained

However, if foo is overloaded, this becomes more complex:

struct S
{
void foo(int x) {}
void foo(string s) {}
}

S s;
auto dg = &s.foo; // which one? Compiler chooses!

Turns out, it's somewhat possible to specify, but it can be
painful/uintuitive:

auto dg = cast(void delegate(string))&s.foo; // oops, what if I use the
wrong delegate signature, or S.foo is changed later!

void delegate(string) dg = &s.foo;

Andrei

Reply via email to