On the richness of C++

Sean Kelly sean at invisibleduck.org
Sun Apr 27 08:15:26 PDT 2008


Bruno Medeiros wrote:
> Sean Kelly wrote:
>> == Quote from Sean Kelly (sean at invisibleduck.org)'s article
>>> == Quote from Janice Caron (caron800 at googlemail.com)'s article
>>> I think the problem is that functions and delegates are called 
>>> differently.
>>> That is, the context pointer is passed as an invisible first 
>>> parameter to
>>> a delegate, while functions have no such invisible argument.  
>>> Interestingly,
>>> because the first parameter of a D function is supposed to be passed 
>>> in a
>>> register (EAX) on x86, I think you're right that it should be 
>>> possible to
>>> allow such efficient conversion so long as the D calling convention
>>> accounts for it properly (and the platform supports such things).
>>
>> Er... forget that.  A D function would obviously expect its first 
>> argument to
>> be in EAX regardless of whether it's a delegate.  Some conversion 
>> would be
>> necessary unless I'm missing something.
> 
> Well, if that doesn't work, there is nothing preventing the *changing* 
> the D function calling ABI, right? Or are there some performance, or 
> other issues?

Well... I suppose the D ABI could state that if a function has a context 
pointer then this value is passed in a specific register (EAX), and that 
the register may not be used for parameter passing otherwise.  Then I 
think it should be possible to call any D function as if it were a delegate.


Sean



More information about the Digitalmars-d mailing list