Pragma msg goes out of memory when supplied with large data.
realhet
real_het at hotmail.com
Wed May 21 15:20:57 UTC 2025
On Wednesday, 21 May 2025 at 14:40:21 UTC, realhet wrote:
> On Wednesday, 21 May 2025 at 14:00:56 UTC, realhet wrote:
> Small program to reproduce.
I'm lucky:
`pragma(msg, "Here comes the big data: ", data);`
With this simple way I managed to put 16MB large data through it
in no time.
It was new to me that pragma_msg don't care about the actual type
of data type, it just copies the raw bytes to the stderr as fast
as it can.
And if I use a high level functional transformation on it, it
goes terrible slow.
For example the complexity inside text() has a really big penalty
in Compile Time.
Because of this, I wanted to make a simpler non-functional
transformation myself:
```d
string transform(string a)
{
auto b = cast(ubyte[])a.dup;
foreach(ref ch; b) if(ch=='x') ch = 'y';
return cast(string)b;
}
```
For my big surprise, with this simple thing I managed to trigger
that same out of memory 'bug'.
Now I only have one question: Why are these simple looking things
are so slow in compile time? I learned that there is a different
limited runtime environment in compile-time, but I don't
understand. Anyone can help with some clues please?
More information about the Digitalmars-d-learn
mailing list