www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why I can't use array in compile-time struct creation?

It is forbidden by specification, but an interesting reason.

for example:

struct S
{
     static S opCall()
     {
         S res;
         int a,b,c,d;
         int[10] data; // If I comment out this line compilation goes 
smoothly
         return res;
     }
}

void main()
{
     static S s = S();
}

struct_array.d(14): Error: cannot evaluate opCall() at compile time
struct_array.d(14): Error: cannot evaluate opCall() at compile time
Dec 13 2008