DIP 57: static foreach

Kenji Hara k.hara.pg at gmail.com
Sun Mar 9 23:40:01 PDT 2014


2014-03-10 6:31 GMT+09:00 Timon Gehr <timon.gehr at gmx.ch>:

> http://wiki.dlang.org/DIP57
>
> Thoughts?
>

>From the "Semantics" section:

> For static foreach statements, break and continue are supported and
treated like for foreach statements over tuples.

This is questionable sentence. On the foreach with tuple iteration, break
and continue have no effect for the unrolling.

void main()
{
    import std.typetuple, std.stdio;

    foreach (i; TypeTuple!(1, 2, 3))
    {
        static if (i == 2) continue;
        else static if (i == 3) break;

        pragma(msg, "CT: i = ", i); // prints 1, 2, and 3 in CT
        writeln("RT: i = ", i);     // prints only 1 in RT
    }
}

So, I think that static foreach *cannot* support break and continue as same
as foreach with tuples.

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140310/9a14c6e5/attachment.html>


More information about the Digitalmars-d mailing list