Re: [Vala] array declaration



Thanks Frederik that explains why you can't pass a fixed size array as
a parameter.

Vala supports two types of arrays:

1) dynamically heap-allocated arrays:

Vala, Java, C#: int[] a = new int[5];
C++: int* a = new int[5];
C: int* a = malloc (5 * sizeof (int));


2) inline/stack-allocated fixed-size arrays:

Vala: int a[5];
C++: int a[5];
C: int a[5];
Java: not supported
C#: unsafe { int* a = stackalloc int[5]; }


@pancake: 'new' combined with the latter type of array does not make
sense, since the 'new' keyword stands for dynamic alloation on the
heap. The Vala compiler should refuse to compile something like
'int a[] = new int[5]'. So it's obviously a bug.



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