Before it's too late: delegate calling convention

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Nov 1 13:34:23 PST 2006


"Gregor Richards" <Richards at codu.org> wrote in message 
news:4548CD75.80803 at codu.org...

> And a solution that's less nasty: Allow casting of function pointers to 
> delegate pointers by automatic thunktion generation.

I like that a lot better.  But if you're wrapping a function pointer in a 
delegate reference, is a thunk really needed?  I mean, the function won't be 
accessing the context pointer, so why not just set the delegate's context 
pointer to null?

i.e.

int foo()
{

}

int delegate() bar = cast(int delegate())&foo;
// bar's function address is &foo, and bar.ptr == null 





More information about the Digitalmars-d mailing list