Forcing inlining of delegates and lazy

FinalEvilution FinalEvilution at gmail.com
Tue Sep 1 03:01:00 UTC 2026


On Monday, 31 August 2026 at 17:36:55 UTC, ABrightLight wrote:
> Hello. I am trying to figure out some way to get delegates or 
> lazy parameters to get inlined into the function they are 
> called with. For example, if we take this starting code:

I tried building a simple program with the ldc compiler and 
optimization and it inlined correctly. At least in this case.
```
import std.stdio : writeln;

void main()
{
     int x;
     3.times(writeln(x++));
}

pragma(inline, true)
void times(int n, lazy void exp)
{
     while (n--)
         exp();
}
```

Are you possibly using dmd? It doesn't have the fancy optimizing 
backends that gdc and ldc have.


More information about the Digitalmars-d mailing list