[Issue 17156] Local function declaration not inferred to be static

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat May 13 08:58:02 PDT 2017


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

--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to Eyal from comment #2)
> I see, but this would not be a problem if function was automatically
> convertible to delegate (std.functional : toDelegate).
> 
> Is there any reason that you cannot hand over functions when delegates are
> expected?

Yes. The ABI of how functions and delegates are passed ensures one cannot be
treated as the other.

The compiler could, behind the curtain, generate a wrapper to do this (as you
suggest), but that has negative performance implications that users could find
very surprising because it would be hidden from them. I prefer the library
template solution for that reason.

--


More information about the Digitalmars-d-bugs mailing list