Simple array init question
Bill Baxter
dnewsgroup at billbaxter.com
Mon Apr 9 20:36:53 PDT 2007
Derek Parnell wrote:
> On Mon, 09 Apr 2007 20:38:03 -0400, Dan wrote:
>
>>> Sorry, "int[5,5]" only compiles because of the obscure comma operator.
>> According to the D spec, that should compile as a rectangular array. I haven't tried it. I have read the spec.
>>
>> See:
>> http://digitalmars.com/d/arrays.html
>> and visit "Rectangular Arrays".
>
> I don't read the spec that way at all.
>
> "Fortunately, D static arrays, while using the same syntax, are implemented
> as a fixed rectangular layout:
>
> double[3][3] matrix;
>
> declares a rectangular matrix with 3 rows and 3 columns, all contiguously
> in memory.
>
> In other languages, this would be called a multidimensional array and
> be declared as:
>
> double matrix[3,3];
> "
>
> To me, this is say that D uses the [3][3] syntax but *other* languages use
> the [3,3] syntax.
>
>
Dan is not the first one to misread that particular passage in that
particular way. It needs to be rewritten. The fact that the [3,3]
appears in a code box just like other D code is hugely misleading. It
should at least be followed by an ALL CAPS comment:
double matrix[3,3]; // NOT D CODE!
But anyway, there's really no reason for that last sentence. Just cut
it, I say. The docs are supposed to describe what you can do in *D* and
how to do it. How other (vague and unspecified) languages do it is
irrelevant.
--bb
More information about the Digitalmars-d
mailing list