Proposal: struct and array literal syntax

BCS BCS at pathlink.com
Fri Jun 23 09:07:40 PDT 2006


Andrei Khropov wrote:
> Derek Parnell wrote:
> 
> 
>>Now a 'rectangular' array ...
>>
>>  int[][]![
>>      int[]![1,2,3,4],
>>      int[]![5,6,7,8],
>>      int[]![9,0,1,2],
>>      int[]![3,4,5,6],
>>    ]
>>
>>Hmmm ... appears to do okay. 
> 
> Well, in the last case inner int[]! s appear to be a syntactic overhead.
> 
> I'm still waiting for better handling of multidimensional rectangular arrays
> (not less effective "jagged").
> 

As to the non-jagged issue, how about some sort of wild card syntax like:

	// legal	
int[$][$] = ![ ![1,2,3], ![4,5,6], ![7,8,9]];

	// illegal	
int[$][$] = ![ ![1], ![4,5], ![7,8,9]];

the "$" would indicate that the length of each sub array must be the 
same. Read it something like "an array of ints that is some length by 
some length."



More information about the Digitalmars-d mailing list