www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Initialization of structs by member names

According to the current documentation 
http://dlang.org/struct.html, under "Static Initialization of 
Structs":
The static initializer syntax can also be used to initialize 
non-static variables, provided that the member names are not 
given. The initializer need not be evaluatable at compile time.

void test(int i)
{
     S q = { 1, i }; // q.a = 1, q.b = i, q.c = 0, q.d = 7
}


But actually the following code does compile and works as 
expected, even though the variable isn't static:

void test(int i)
{
     S q = { c:1, a:i }; // q.a = 1, q.b = i, q.c = 0, q.d = 7
     writeln(q);
}

void main() {
     test(5);
}

Using DMD64 D Compiler v2.066.1, output is:
S(5, 0, 1, 7)


Is the documentation out-dated? Or is the behavior "not-defined"?

Thanks, Alex
Jun 02 2015