Trying to understand multidimensional arrays in D

ag0aep6g anonymous at example.com
Tue Dec 22 14:35:30 UTC 2020


On 22.12.20 15:15, Mike Parker wrote:
> On Tuesday, 22 December 2020 at 13:59:54 UTC, Rekel wrote:
> 
>>
>> I am curious by the way, what do you think of the [][4]Row suggestion 
>> I gave? In a way you'd have your 🍰 & could eat it too, i think ^^
>> (Still a strange saying to me)
> 
> Currently, D's variable declaration syntax is consistent and, IMO, make 
> sense:
> 
> Type Name | Extra Tokens | SymbolName
> Foo           *               a;
> Foo           [4]             b;
> (Foo          [4])[]          c;
> 
> [][4]Foo is completely backwards from and inconsistent with the pointer 
> declaration syntax. We shouldn't want to intentionally introduce 
> inconsistencies.

Flip the pointer syntax, too:

     *Foo a; /* a pointer to a Foo */
   [4]Foo b; /* an array of four Foos */
[][4]Foo c; /* a dynamic array of arrays of four Foos each */

But now we're no longer C-like, I guess.


More information about the Digitalmars-d-learn mailing list