Re: [Vala] Can fixed-size arrays be initialized?



Il giorno gio, 03/03/2011 alle 17.34 +0000, Graham Whelan ha scritto:
dynamic array syntax:
const int[] a = {1, 2, 3}; /* compiles*/

This is not dynamic at all! It's constant; look at the generated C code!

int[] a = {1, 2, 3};       /* compiles */


fixed-size array syntax:
const a[] = {1, 2, 3};     /* compiles */

Including the type:
        const int a[] = {1, 2, 3};
it's exactly equal to:
        const int[] a = {1, 2, 3};

And they both are constant.

int a[] = {1, 2, 3};       /* does not compile */

Yes, because in this case the type is int, not int[]. However it could
be added an alias to const int a[] = {1, 2, 3};.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]