simple ABI change to enable implicit conversion of functions to delegates?

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Tue May 16 06:43:24 PDT 2017


On 05/16/2017 02:57 PM, Jerry wrote:
> My understanding is that we want to pass functions to functions which
> takes delegates transparently, or is it something more involved here?

That's about it. It's not a big thing. Would just be nice to have.

> Anyway if that is everything, then why not add a template to the D
> runtime which casts the function to a delegate?

You can't currently cast a function (pointer) to a delegate. You have to 
create a wrapper delegate that calls the function. 
std.functional.toDelegate does this.

> And if that wrapper function is only called by the compiler it does not
> even have to be a template. Templetation just provides type safety in
> this case.

Walter doesn't like the idea of doing toDelegate automatically. He says 
it has "negative performance implications that users could find very 
surprising" [1].



[1] https://issues.dlang.org/show_bug.cgi?id=17156


More information about the Digitalmars-d mailing list