Re: [Vala] how to declare multi-dimensional arrays in Genie?
On 7/15/2010 7:34 PM, Jamie McCracken wrote: On Thu, 2010-07-15 at 19:26 -0400, Ron Murawski wrote: I wanted the multi-dimensional array in the data area, not on the stack. In C: int my_array[64][13]; int main(int argc, **char argv) { my_array[7][7] = 7; // more stuff return 0; } my_array is allocated on the stack in the above example the previous posts have shown how to do it on the heap (via use of new array) but as thats not what you want I would suggest filing a bug/feature request for vala to support stack allocation of multi-dimensional arrays jamie I am perfectly happy using the heap for multi-dimensional arrays. I am much too new to the language to be making language feature requests. Maybe next year... ;-) Thanks again to everyone! Ron ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to declare multi-dimensional arrays in Genie?
On Thu, 2010-07-15 at 11:52 +0200, Nicolas wrote: Hi Ron, Try this: const myarray : array of uint64 = {13, 64} Isn't this a mono-dimensional array with 2 elements ? Xav ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to declare multi-dimensional arrays in Genie?
Isn't this a mono-dimensional array with 2 elements ? Xav Hi, I'm not an expert nor a real developer, but multidimensional array seem to be like this: var myarray = new array of uint64[3, 2] = {{13, 64}, {14, 65}, {15, 66}} or myarray : array of uint64[3, 2] = new array of uint64[3, 2] = {{13, 64}, {14, 65}, {15, 66}} Is this correct ? Someone can confirm ? Nicolas. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to declare multi-dimensional arrays in Genie?
On 7/15/2010 6:23 AM, Nicolas wrote: Hi, I'm not an expert nor a real developer, but multidimensional array seem to be like this: var myarray = new array of uint64[3, 2] = {{13, 64}, {14, 65}, {15, 66}} or myarray : array of uint64[3, 2] = new array of uint64[3, 2] = {{13, 64}, {14, 65}, {15, 66}} Is this correct ? Someone can confirm ? Nicolas. Both of the above multi-dimensional array declarations work as intended, but they do not seem to be global. Ron ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to declare multi-dimensional arrays in Genie?
Both of the above multi-dimensional array declarations work as intended, but they do not seem to be global. Is this what you are trying to do? int [,] arr; public void main(string [] args) { arr = new int[3,4]; arr[0,0] = 1; arr[1,1] = 2; stderr.printf(%d:%d\n, arr[0,0], arr[1,1]); } Hope that helps ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to declare multi-dimensional arrays in Genie?
On Thu, 2010-07-15 at 18:34 -0400, Ron Murawski wrote: On 7/15/2010 1:45 PM, Robert Powell wrote: Both of the above multi-dimensional array declarations work as intended, but they do not seem to be global. Is this what you are trying to do? int [,] arr; public void main(string [] args) { arr = new int[3,4]; arr[0,0] = 1; arr[1,1] = 2; stderr.printf(%d:%d\n, arr[0,0], arr[1,1]); } Hope that helps Thanks, Robert! That's exactly what I was trying to accomplish, but I was trying to do it all at compile-time. Hot diggety! I'm about to write a chess program in Genie! :-) Here's Robert's example translated from Vala to Genie: [indent=4] //int [,] arr; arr : array of int[,] // declare array name with global scope //public void main(string [] args) { init //arr = new int[3,4]; arr = new array of int[3,4] // allocate the array arr[0,0] = 1; // initialize it arr[1,1] = 2; stderr.printf(%d:%d\n, arr[0,0], arr[1,1]); // print it //} I want to make certain I am understanding this correctly: 1. All multi-dimensional arrays in Vala/Genie *must* be allocated at run-time, not at compile-time 2. Optionally, the multi-dimensional array name can be declared a global name Is this correct? if you mean you want to allocate multi dimensional arrays on the stack like ordinary arrays then i dont know if vala supports that If it does then it looks like a bug in Genie jamie ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to declare multi-dimensional arrays in Genie?
On 7/15/2010 6:50 PM, Jamie McCracken wrote: On Thu, 2010-07-15 at 18:34 -0400, Ron Murawski wrote: On 7/15/2010 1:45 PM, Robert Powell wrote: Both of the above multi-dimensional array declarations work as intended, but they do not seem to be global. Is this what you are trying to do? int [,] arr; public void main(string [] args) { arr = new int[3,4]; arr[0,0] = 1; arr[1,1] = 2; stderr.printf(%d:%d\n, arr[0,0], arr[1,1]); } Hope that helps Thanks, Robert! That's exactly what I was trying to accomplish, but I was trying to do it all at compile-time. Hot diggety! I'm about to write a chess program in Genie! :-) Here's Robert's example translated from Vala to Genie: [indent=4] //int [,] arr; arr : array of int[,] // declare array name with global scope //public void main(string [] args) { init //arr = new int[3,4]; arr = new array of int[3,4] // allocate the array arr[0,0] = 1; // initialize it arr[1,1] = 2; stderr.printf(%d:%d\n, arr[0,0], arr[1,1]); // print it //} I want to make certain I am understanding this correctly: 1. All multi-dimensional arrays in Vala/Genie *must* be allocated at run-time, not at compile-time 2. Optionally, the multi-dimensional array name can be declared a global name Is this correct? if you mean you want to allocate multi dimensional arrays on the stack like ordinary arrays then i dont know if vala supports that If it does then it looks like a bug in Genie jamie I wanted the multi-dimensional array in the data area, not on the stack. In C: int my_array[64][13]; int main(int argc, **char argv) { my_array[7][7] = 7; // more stuff return 0; } The space for the array is reserved by the C compiler at compile-time in the data area, the array is guaranteed to be zeroed, and the name 'my_array' is recognized globally by all modules, possibly with the help of extern statements. I was trying to do the same in Vala/Genie, but this does not seem to be possible. Best regards, Ron ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to declare multi-dimensional arrays in Genie?
On Thu, 2010-07-15 at 19:26 -0400, Ron Murawski wrote: I wanted the multi-dimensional array in the data area, not on the stack. In C: int my_array[64][13]; int main(int argc, **char argv) { my_array[7][7] = 7; // more stuff return 0; } my_array is allocated on the stack in the above example the previous posts have shown how to do it on the heap (via use of new array) but as thats not what you want I would suggest filing a bug/feature request for vala to support stack allocation of multi-dimensional arrays jamie ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list