On Saturday, 6 January 2018 at 23:25:58 UTC, Ali Çehreli wrote:
Is 'static foreach' sufficient for all needs or is there any value for regular foreach over compile-time sequences?

Code unrelated to the question:

import std.stdio;

void main() {
    // Old style compile-time foreach. This still works
    // when 'static' is uncommented below.
    import std.meta : AliasSeq;
    /* static */ foreach (i; AliasSeq!(1, "hello", 2)) {
        writeln(i);
    }

    // Proper 'static foreach'.
    import std.range : iota;
    import std.algorithm : map;
    static foreach (i; 3.iota.map!(a => a * 10)) {
        writeln(i);
    }
}

Ali

No it's not.
When you can use the old style do so. Since it puts less stress on the compiler in the general case.

Reply via email to