Created attachment 1844
Main source file
I lost an excellent potential contributor because he was not impressed with D, after encountering bugs and regressions.
The following program he wanted to compile but exhausted memory.
-------------------------------------------------------
import std.stdio;
import std.string;
import std.range;
import std.array;
import std.typecons;
import std.complex;
enum TEXT = import("shape-L8.txt");
enum Tuple!(double, Complex!double)[] DATA =
mixin(TEXT.transformLTSpiceToCode);
string transformLTSpiceToCode(string text)
{
string result;
result.reserve(1_000_000);
result ~= "[";
foreach (string line; text.lineSplitter.dropOne) {
string[] fields = line.split!`a == ' ' || a == '\t' || a == ','`.array;
result ~= "std.typecons.Tuple!(double, std.complex.Complex!double)(";
result ~= fields[0];
result ~= ",Complex!double(";
result ~= fields[1];
result ~= ",";
result ~= fields[2];
result ~= ")),\n";
}
result ~= "]";
return result;
}
void main(string[] args)
{
writeln(DATA);
}
-------------------------------------------------------
To a seasoned D programmer, it is obvious why the program uses up all memory: it uses tuples, std.complex, lazy ranges, arrays liberally at CTFE. It is of course possible to make it work at CTFE with more pedestrian code.
But a newfound D user will just dismiss the language without knowing he is perhaps amongst the only to use such a costly CTFE program.
And then the compiler crashing is an ICE.
## To reproduce
1. unzip the attached file and get shape-L8.txt
2. run the above program
DMD will crash after exhausting memory.
Better outcome with -lowmem, who caps memory usage at 100mb.
Comment #1 by robert.schadek — 2024-12-13T19:22:12Z