delegates vs functions => practical consequences

John Chapman johnch_atms at hotmail.com
Wed Apr 18 15:37:04 PDT 2012


On Wednesday, 18 April 2012 at 21:07:08 UTC, Xan wrote:
> Hi,
>
> I want to know what is most interesting for me: delegates or 
> functions. I consulted sources but none say the practical 
> consequences of such election.
>
> What can I do and what can't I do with functions and delegates?
> Please, be didactics, I'm a newbee
>
> Thanks,
> Xan.

Well, function pointers can point to static functions, delegates 
cannot. Delegates can point to class/struct methods, function 
pointers cannot. Just use whichever is appropriate for your 
needs. To convert a function pointer to a delegate, call 
std.functional.toDelegate().

See http://dlang.org/function.html#closures


More information about the Digitalmars-d-learn mailing list