On Thu, May 12, 2022 at 02:42:43PM +0000, Anonymouse via Digitalmars-d-learn wrote: [...] > The one thing that has caused me most anguish and woe is hands-down > https://issues.dlang.org/show_bug.cgi?id=18026 though. It hasn't bit > me for a while now, but the feeling of uncertainty, that the compiler > might just suddenly after an innocent change no longer compile your > project, seemingly outside of your control, is just... disheartening > when it happens.
static foreach isn't meant to handle large loops. Writing `static foreach (i; 0 .. 60000)` is generally a bad idea; my suspicion is that the compiler ran out of stack space). It's more for unfolding groups of statements or declarations like cases in a switch-statement. For complex loops, what you really want is to use CTFE, which has a proper interpreter that can execute real code, instead of static foreach. What I'd do in the case described in comment 20 is to use CTFE to generate an array of indices that satisfy the predicate (it can create this array however it wants), then static foreach over this array, instead of iterating from 0 to 60000 directly. Or, in certain cases, you might want to just try straight foreach instead of static foreach, just make a tuple of your indices first and it will auto-unroll. T -- Не дорог подарок, дорога любовь.