On Wednesday, 21 May 2025 at 14:00:56 UTC, realhet wrote:
Hi,

Small program to reproduce.
```d
import std;

string doit(string data)()
{
        static foreach(i; 0..256)
        {
pragma(msg, i"Here goes lots of data: $(cast(ubyte[])data)".text);
        }
        return "dummy";
}

static immutable storedData = doit!("x".replicate(256));

void main(){ writeln(storedData.length, storedData.all!"a=='x'"); }
```

run with: `ldc2 testPragma.d > a.txt 2>&1`


This is not so fast but works.

If I remove the static foreach(i; 0..256), it will never complete, it exponentially runs out of memory.

I'm basically searching for the fastest version of the inverse of `import(file)`.

I think the operations inside the pragma(msg, xxx) construct has a really high cost. I will experiment more.


Reply via email to