digitalmars.D - arrays again :)
- Ivan Senji (28/28) May 04 2004 There are many ways (for example) to create a twodimensional
- Drew McCormack (9/15) May 04 2004 I agree. I think this would be more logical than the current state of
- Norbert Nemec (14/36) May 04 2004 Be careful there! Statically sized arrays are something different from
- Ivan Senji (8/44) May 04 2004 array
- Norbert Nemec (4/19) May 05 2004 I have just started to write up a detailed proposal for multidimensional...
- Ivan Senji (5/24) May 05 2004 for
There are many ways (for example) to create a twodimensional dynamic array in D: (a) int[][] p1; p1 = new int[][15]; for(int i=0;i<p1.length; i++) { p1[i] = new int[i+5]; } (b) int[][] p2; for(int i=0;i<15; i++) { p2 ~= new int[i+5]; } (c) int[][] p3; p3.length = 15; for(int i=0;i<15; i++) { p3[i].length=i+5; } and it would be easy to combine (a) and (b) to have two more ways. There are 0 ways to create a rectangular arrays in D dynamically and it would be great if there were only one, wouldn't it :) int [][] rect = new int[10][10]; or int [,] rect = new int[10][10]; or int [;] rect = new int[10][10]; or anything else!
May 04 2004
There are 0 ways to create a rectangular arrays in D dynamically and it would be great if there were only one, wouldn't it :) int [][] rect = new int[10][10]; or int [,] rect = new int[10][10]; or int [;] rect = new int[10][10]; or anything else!I agree. I think this would be more logical than the current state of affairs where you have static arrays. Static arrays are not needed if you can create rectangular arrays on the heap. int[4][5] a; could simply be replaced by int[][] a = new int[4][5]; This would be more consistent with the rest of D, where most things are created on the heap. Drew McCormack
May 04 2004
Drew McCormack wrote:Be careful there! Statically sized arrays are something different from dynamically sized arrays. int[3] is a different type from int[4], which again is different from int[], even if that has the dynamic size 4. There are plenty of uses for statically sized arrays that are created on the stack (or directly inside of structs and classes) and D definitely needs both (and - for 1-d already has) both of them well distinguished. The idea of having int[][] a = new int[10][10] is very misleading. int[][] just is no rectangular array, but a ragged array (even, if, by chance, all the rows have the same size). If you really want to extend the language, go for real rectangular arrays, where my suggestion for a good syntax would be int[,] a = new int[10,10]There are 0 ways to create a rectangular arrays in D dynamically and it would be great if there were only one, wouldn't it :) int [][] rect = new int[10][10]; or int [,] rect = new int[10][10]; or int [;] rect = new int[10][10]; or anything else!I agree. I think this would be more logical than the current state of affairs where you have static arrays. Static arrays are not needed if you can create rectangular arrays on the heap. int[4][5] a; could simply be replaced by int[][] a = new int[4][5]; This would be more consistent with the rest of D, where most things are created on the heap. Drew McCormack
May 04 2004
"Norbert Nemec" <Norbert.Nemec gmx.de> wrote in message news:c78ckg$cp2$1 digitaldaemon.com...Drew McCormack wrote:arrayBe careful there! Statically sized arrays are something different from dynamically sized arrays. int[3] is a different type from int[4], which again is different from int[], even if that has the dynamic size 4. There are plenty of uses for statically sized arrays that are created on the stack (or directly inside of structs and classes) and D definitely needs both (and - for 1-d already has) both of them well distinguished. The idea of having int[][] a = new int[10][10] is very misleading. int[][] just is no rectangular array, but a raggedThere are 0 ways to create a rectangular arrays in D dynamically and it would be great if there were only one, wouldn't it :) int [][] rect = new int[10][10]; or int [,] rect = new int[10][10]; or int [;] rect = new int[10][10]; or anything else!I agree. I think this would be more logical than the current state of affairs where you have static arrays. Static arrays are not needed if you can create rectangular arrays on the heap. int[4][5] a; could simply be replaced by int[][] a = new int[4][5]; This would be more consistent with the rest of D, where most things are created on the heap. Drew McCormack(even, if, by chance, all the rows have the same size). If you really want to extend the language, go for real rectangular arrays, where mysuggestionfor a good syntax would be int[,] a = new int[10,10]Exactly what i had in mind. I really hope D gets this because support for dynamic jagged arrays is great, and this is just one little part that is missing. Maybe not for D 1.0 but some later version should really corect this.
May 04 2004
Ivan Senji wrote:I have just started to write up a detailed proposal for multidimensional, rectangular arrays in D. I have a pretty clear vision for them and hope to have it all written and uploaded by next week.The idea of having int[][] a = new int[10][10] is very misleading. int[][] just is no rectangular array, but a raggedarray(even, if, by chance, all the rows have the same size). If you really want to extend the language, go for real rectangular arrays, where mysuggestionfor a good syntax would be int[,] a = new int[10,10]Exactly what i had in mind. I really hope D gets this because support for dynamic jagged arrays is great, and this is just one little part that is missing. Maybe not for D 1.0 but some later version should really corect this.
May 05 2004
"Norbert Nemec" <Norbert.Nemec gmx.de> wrote in message news:c7a7q3$6fi$1 digitaldaemon.com...Ivan Senji wrote:forThe idea of having int[][] a = new int[10][10] is very misleading. int[][] just is no rectangular array, but a raggedarray(even, if, by chance, all the rows have the same size). If you really want to extend the language, go for real rectangular arrays, where mysuggestionfor a good syntax would be int[,] a = new int[10,10]Exactly what i had in mind. I really hope D gets this because supportReally GREAT :) I hope Walter reads it and likes it!!dynamic jagged arrays is great, and this is just one little part that is missing. Maybe not for D 1.0 but some later version should really corect this.I have just started to write up a detailed proposal for multidimensional, rectangular arrays in D. I have a pretty clear vision for them and hope to have it all written and uploaded by next week.
May 05 2004