proposal : functions->delegates

Stewart Gordon smjg_1998 at yahoo.com
Sun Mar 4 10:37:25 PST 2007


Lionello Lunesu Wrote:

> 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.

Well, it certainly used to work under at least some 
platform/compiler combinations.

I've looked, and it would appear to be a mere matter of whether 
a context pointer is pushed to the stack as well.  The ABI 
doesn't make it clear whether parameters/local variables are 
addressed from the bottom or the top of the stack frame.  From 
my experiment, it would appear to be the bottom.

<snip>
> 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.

Indeed.  And one way that's been suggested is to pass the 
context pointer in a register rather than pushing it to the 
stack.

Stewart.




More information about the Digitalmars-d mailing list