How to know whether to use function or delegate

Don Clugston dac at nospam.com.au
Mon Jul 17 07:02:57 PDT 2006


Reiner Pope wrote:
>> Example #3 - You can still use it with a function, by wrapping it in 
>> an anonymous delegate:
>> # void bar (int a) {
>> #   /*do stuff*/
>> # }
>> #
>> # foo((int a) {
>> #   bar(a);
>> # });
> Is it really necessary to *wrap* it? I'm surprised there isn't a cast to 
> do it.

The calling convention is actually different, you need to create a 
'thunk' to convert function to delegate. The compiler doesn't do this 
for you yet.



More information about the Digitalmars-d-learn mailing list