On Mon, Feb 24, 2020 at 10:41:16AM -0500, Steven Schveighoffer via Digitalmars-d-announce wrote: [...] > I will also note that we did something very similar with > switch(string), where prior to this the compiler did all the "heavy > lifting" of generating the code to convert strings into integers. Now > it's done via a template which accepts all the strings as parameters. > I don't think it was a bad change, and I'm sure it increased compile > times and compiler memory usage.
No kidding, at one point it was making Phobos uncompilable except for machines with huge gobs of RAM, because std.datetime had this gigantic switch statement over, like, *every* locale name that exists in the world, and it was causing a gigantic explosion of template bloat. I think the solution that was eventually adopted was to replace that switch with something else, which is not altogether a bad thing I suppose, but still, it does put to question the practicality of having a template generate code for a switch statement with >1000 string items. > We shouldn't shy away from this type of stuff, but rather invest in > making it better. [...] Agreed. I think after newCTFE is finally merged, the next major item to tackle is how to improve the performance of template-heavy code. T -- Don't modify spaghetti code unless you can eat the consequences.