UFCS and delegates

Daniel Murphy yebbliesnospam at gmail.com
Sat Mar 15 04:02:23 PDT 2014


"Steve Teale"  wrote in message news:uhledfeisciwpvtvmhbp at forum.dlang.org...

> Yes, I'm asking for the wrong thing. What I should have said is that given 
> UFCS, should there be an alternate way of initializing a delegate, 
> something along the lines of:
>
> void delegate(int) dg = (a, &bar);
>

Well, if you know the instance, you can do this:

void delegate(int) dg = (int v) { a.bar(v); }

But this would have to go inside main.

If you want to supply the instance later, then you could use toDelegate on 
'bar' to get you a delegate, or write a wrapping delegate yourself, but it 
will naturally have two parameters. 



More information about the Digitalmars-d mailing list