Can I pass a function by parameter?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 7 20:37:44 PDT 2014


On Sunday, 7 September 2014 at 21:42:31 UTC, Jakob Ovrum wrote:
> On Sunday, 7 September 2014 at 21:31:11 UTC, AsmMan wrote:
>> Thank you too. Btw, why the & operator in this syntax? I used 
>> to think ref keyword sort of C's T** and & operator is 
>> neeeded.. or is it because f can be a function called without 
>> pass any parameter?
>
> In D, the address-of operator has to be used to get a function 
> pointer or delegate from a function or member function. This is 
> unlike C and C++, where the function is implicitly convertible 
> to its function-pointer type.
>

In fact the distinction is done by C and C++ only. Everything 
else, including every other language and the hardware they run on 
only understand what you call function pointer.

What you call a function is simply an accident of history made 
many years ago in C when people had no idea what they were doing, 
and so we repeat it.


More information about the Digitalmars-d mailing list