foreach in compile time function?

Johan Granberg lijat.meREM at OVE.gmail.com
Sat Mar 10 04:03:49 PST 2007


Is this code supposed to work?

char[] test(char[] d)
{
        char[] v="";
        foreach(dchar c;d)
                v~=c;
        return v;
}
void main()
{
        const a=test("test");
        printf("%*.s",a);
}

I just get this error but I'm unsure if it is a bug or a limitation.

johan at Cyclop:~/Desktop$ gdc -o test ctforeach.d 
ctforeach.d:5: Error: cannot evaluate _aApplycd1(d,__foreachbody1) at
compile time
ctforeach.d:11: Error: cannot evaluate test("test") at compile time
johan at Cyclop:~/Desktop$ 



More information about the Digitalmars-d-learn mailing list