Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-03 Thread Chris Cain
On Wednesday, 3 April 2013 at 15:56:31 UTC, Ali Çehreli wrote: I wonder whether it would complicate syntax? (But * already has so many meanings that maybe that would not be too bad.) I doubt it, but maybe. Plenty of languages exist that do a left-to-right reading of types and they seem to work

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-03 Thread Chris Cain
On Wednesday, 3 April 2013 at 15:44:52 UTC, ixid wrote: I wasn't arguing for the old style, the new declarations should have read from left to right so [6][5][string]int and then you access the elements in the same order that you assigned them, that seems far less confusing and leaves less ro

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-03 Thread Ali Çehreli
On 04/02/2013 07:28 PM, Chris Cain wrote:> On Wednesday, 3 April 2013 at 01:30:19 UTC, ixid wrote: > What's a int*? It's a pointer to an int. Why isn't it a *int, then? I wonder whether it would complicate syntax? (But * already has so many meanings that maybe that would not be too bad.) > H

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-03 Thread ixid
On Wednesday, 3 April 2013 at 02:28:55 UTC, Chris Cain wrote: On Wednesday, 3 April 2013 at 01:30:19 UTC, ixid wrote: How can you call the new syntax better? You assign arrays' lengths in the opposite to that that you access them. It's a horrible design mistake. Unfortunately, I have to agree

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-02 Thread bearophile
Chris Cain: Really though, bearophile has it right. C (and, D, transitively) made a huge mistake in type declarations. They ought to be read from left to right (like Pascal). C is crazy in that they've designed it so you read types in a spiral pattern. Maybe you are talking more about Go he

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-02 Thread Chris Cain
On Wednesday, 3 April 2013 at 01:30:19 UTC, ixid wrote: How can you call the new syntax better? You assign arrays' lengths in the opposite to that that you access them. It's a horrible design mistake. Unfortunately, I have to agree that the new syntax is better. int[5][6] is confusing as a ty

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-02 Thread ixid
On Monday, 1 April 2013 at 09:30:23 UTC, monarch_dodra wrote: On Monday, 1 April 2013 at 08:42:45 UTC, Nicholas Smith wrote: Ali, thanks for the justification. It makes enough sense, and at least int[][](2, 3) matches the order in which you access the elements. I agree with Bearophile though

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-01 Thread monarch_dodra
On Monday, 1 April 2013 at 10:52:34 UTC, Andrej Mitrovic wrote: On 4/1/13, Ali Çehreli wrote: Obviously, like C and C++, D does not have multi-dimensional arrays but D's array of array syntax is consistent. Does not have *rectangular* multi-dimensional arrays. :) Actually, D does have part

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-01 Thread Andrej Mitrovic
On 4/1/13, Ali Çehreli wrote: > Obviously, like C and C++, D does not have multi-dimensional arrays but > D's array of array syntax is consistent. Does not have *rectangular* multi-dimensional arrays. :)

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-01 Thread monarch_dodra
On Monday, 1 April 2013 at 08:42:45 UTC, Nicholas Smith wrote: Ali, thanks for the justification. It makes enough sense, and at least int[][](2, 3) matches the order in which you access the elements. I agree with Bearophile though that the syntax is very messy when you're mixing array types a

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-01 Thread Nicholas Smith
Ali, thanks for the justification. It makes enough sense, and at least int[][](2, 3) matches the order in which you access the elements. I agree with Bearophile though that the syntax is very messy when you're mixing array types and pre/postfix declarations. If you weren't shooting for C fami

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-03-31 Thread Ali Çehreli
On 03/31/2013 06:36 PM, Nicholas Smith wrote:> Hello there, > > So I noticed something about the semantics of multidimensional > fixed-length array vs slice initialization: > > Code: > > int[2][3] array; Obviously, like C and C++, D does not have multi-dimensional arrays but D's array of array s

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-03-31 Thread bearophile
Nicholas Smith: Can anyone explain reasoning behind this? To help confuse you a little more, this syntax is also allowed in D: int array[2][3]; Plus of course a mixed D/C (http://d.puremagic.com/issues/show_bug.cgi?id=5807 ): int[2] array[3]; Mixing fixed size arrays with dynamic ones

Differing semantics between multidimensional fixed-length array and slice initialization

2013-03-31 Thread Nicholas Smith
Hello there, So I noticed something about the semantics of multidimensional fixed-length array vs slice initialization: Code: int[2][3] array; writeln(array.length, " ", array[0].length); int[][] slice = new int[][](2, 3); writeln(slice.length, " ", slice[0].length); Output: 3 2 2 3 So it