Re: [Vala] array declaration



 Should I open a bug? or there's somebody already looking at this issue?

On 07/07/10 23:07, Frederik wrote:
Am 07.07.2010 18:33, Harry Van Haaren wrote:
Hey,

Coming from a C++ background I first tried   typeHere  nameHere[];  too.
I noticed that newer languages seemed to have   type[]  name; configuration
(Java, C# etc).
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.


Best regards

Frederik
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list





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