Newbie initial comments on D language - delegate

Don Clugston dac at nospam.com.au
Wed Jan 30 00:16:27 PST 2008


Janice Caron wrote:
> On 1/30/08, Edward Diener <eddielee_no_spam_here at tropicsoft.com> wrote:
>> You might need plain function pointers but you do not need 'function'. A
>> 'delegate' which encompassed a 'function', with the object pointer part
>> of the delegate being null in that particle case, should be implicitly
>> convertible to a C function pointer.
> 
> In general, the compiler cannot tell at compile time whether or a not
> a value is null at runtime (though in an expression like &f it
> obviously can), so I don't think it can be quite that automatic.
> 
> Nonetheless, I'm inclined to agree that we probably don't need the
> "function" keyword at all.
> 
>     delegate f;
>     oldFashionedCFunction( f.funcptr );

But we still need typedefs and declarations. How do you declare 
oldFashionedCFunction() ?

At the moment, you can have an extern(C) function pointer, ... but what is an 
extern(C) delegate ?
AFAIK, all delegates use the D calling convention. This is not true for 
functions. Clearly several things would need to change.



More information about the Digitalmars-d mailing list