On 06/10/2014 01:18 PM, Tom Browder via Digitalmars-d-learn wrote:

>>> alias int[2] val5[2]; // D: a 2-dimensional array of ints? (int[2][2])
>>> ?
>>
>> Pretty strange. :)
>>
>>      pragma(msg, val5);
>>
>> outputs this:
>>
>> int[2][2]
>
> Okay, checks with my guess.
>
>>> alias int[4] val6[2];     // D:  a 2-dimensional array of ints?
>>> (int[4][2]) ?
>>> alias int val7[2]; // D: a 1-dimensional array of ints? (int[2])
>>> ?
>>
>> I don't know whether those are legal. I hope not. :)
>
> I agree, but they compile! If they are not legal, why am I getting no errors?

I think they are actually legal: This is D's support of C-style array declaration acting the same in alias declaration:

void main()
{
    int a[2];    // C-style
    int[2] b;    // D-style
    static assert(is (typeof(a) == typeof(b)));

    alias int A[2];    // C-style
    alias int[2] B;    // old D-style
    alias C = int[2];  // D-style

    static assert(is (A == B));
    static assert(is (B == C));
}

Ali

Reply via email to