On 24.01.22 03:11, Mathias LANG wrote:
Actually, the idea I had in mind is a little different.
Because a delegate is essentially:
```D
T function (T, Args..)(void* ctx, Args args)
```

It should be possible for the compiler to generate a call to a trampoline function that just forwards to the actual function:
```D
RT _d_trampoline (FT, RT, Args..)(void* ctx, Args args)
{
     return (cast(FT) ctx)(args);
}
```

As far as I'm aware, Walter is against that.

<https://issues.dlang.org/show_bug.cgi?id=17156#c3>:
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.

But that was years ago, maybe he's more open to the idea now.

Reply via email to