proposal : functions->delegates

Lionello Lunesu lio at lunesu.remove.com
Sat Mar 3 22:22:20 PST 2007


Thorsten Kiefer wrote:
> Hi,
> IMHO the compiler should be able to implicitly convert function-pointers into delegate-pointers.
> Before the delegate is passed as argument, the context-pointer is filled in.
> Now when I pass a function, the context-pointer could simply be filled with null.

At the moment it can't, since delegates and function-pointers have 
incompatible calling conventions.

> A problem will be, where to store the context-pointer in a function, as it has no context-pointer (to preserve compatibility with C).

There's another thread on that, "D 2.0 - dalegates to function"

> Or the compiler could implicitly create an anonymous delegate around that function.

That would be a good transitional solution, but because it involves an 
extra function call, I'd still hope the delegate and function-pointer 
calling-convention can be made compatible.

L.



More information about the Digitalmars-d mailing list