D calling convention

Tomas Lindquist Olsen tomas at famolsen.dk
Wed Oct 29 04:19:09 PDT 2008


Lionello Lunesu wrote:
> 
> "Christian Kamm" <kamm-incasoftware at removethis.de> wrote in message 
> news:ge9044$1l0d$1 at digitalmars.com...
>>> Is it possible to solve this problem and also solve the problem 
>>> mentioned
>>> in the thread "implicitly convert function pointers to delegates"? Or 
>>> are
>>> these two mutually exclusive?
>>
>> The two things are separate. Delegates are functions that have the 
>> context
>> argument bound. This is about the passing order of arguments.
>>
> 
> But it matters how delegates pass the context pointer. In order to call 
> functions using a delegate, the functions should silently ignore the 
> context pointer. Which means they should never expect any argument to be 
> passed in that register, or accept an argument on the stack that can be 
> ignore (last one?).. I don't know the details, but I think these two 
> issue are very closely related.
> 
> L.

As I see it there are really 3 different scenarios we'd (do we?) like to 
support:

1) converting a function pointer to a delegate
2) converting a member function pointer to a function pointer
3) converting a delegate to a function pointer

1) seems to be easiest by having the compiler generate a small wrapper 
that takes care of the differences in number of arguments.

2) would be easy to solve given the stuff mentioned in this thread

3) isn't really hard to solve either, at least in terms of LDC (thus 
LLVM), you'd just generate a trampoline.



More information about the Digitalmars-d mailing list