C callbacks?

BCS ao at pathlink.com
Thu Mar 19 14:35:02 PDT 2009


Reply to Chris,

> BCS Wrote:
> 
>> in D the more normal way to write that would be:
>> 
>> typedef bool function(bsp_t* node, void* userData)
>> TCOD_bsp_callback_t;
>> 
> Ahh! Thanks a ton, that seems to work like I needed.
> 
>> C code and delegates are incomparable but C and function pointers are
>> not.
>> 
> I must have been misreading that bit then, thanks for clarifying.
> Listeners/Delegates have always confused me, I really need to do some
> tutorials and try to understand them better.
> 

The under-the-hood for delegate is that they are a function-pointer/context-pointer 
pair where the context pointer is passed like in the this point in methods. 
In fact, for delegates based on objects, the context is the this pointer. 
For local functions and delegate literals, it is a pointer into the stack 
or some such.




More information about the Digitalmars-d-learn mailing list