Can I pass a function by parameter?

Jakob Ovrum via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 7 23:41:42 PDT 2014


On Monday, 8 September 2014 at 06:23:40 UTC, deadalnix wrote:
> On Monday, 8 September 2014 at 05:04:21 UTC, Jakob Ovrum wrote:
>> Function pointers can be converted to delegates through a 
>> simple wrapper function (which is how 
>> std.functional.toDelegate achieves it), but delegates cannot 
>> be wrapped by a function pointer without introducing 
>> additional parameters to the function in order to pass the 
>> context pointer.
>
> Actually, this is possible using a trampoline.

True. AFAICT, a cross-platform, cross-architecture generic 
function for that is non-trivial and might be a neat candidate 
for Phobos.


More information about the Digitalmars-d mailing list