Multi dimensional array question.

bearophile bearophileHUGS at lycos.com
Fri Jul 16 18:50:45 PDT 2010


Heywood Floyd:
> First of all, I definitely think that how arrays are declared now would have to stay just the way it is,
> no matter what. I don't think stuff like that is changeable this late in a language.

Recently I have suggested to remove the syntax:
new int[20];
And allow only:
new int[](20);


>    shared array[3] const array[5] immutable array[] (SList!(int)*)
> 
> Sure, this is too verbose. I agree. Still, I think it's clearer. Much clearer. Verbose, but clear.

I don't know how you can write that in a Go-language-like syntax, maybe it's a bit worse.


> And last, the
>    int[x,y] arr;
> 
> I like it. Simple. Nice. 

It's nice, but unfortunately the comma syntax is present in C too, where:
int[10] arr;
int element = arr[x, y];
Equals to:
int[10] arr;
int element = arr[y];
So in D the usage of comma inside [] was recently forbidden. Keeping some kind of backward compatibility with C is something a kind of damnation (see also switch syntax, tuple syntax, etc).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list