2/3 dimensional arrays + comparison page truncated

Chris Nicholson-Sauls ibisbasenji at gmail.com
Mon Aug 6 00:47:26 PDT 2007


Daniel White wrote:
> A few things. Firstly, what's happened to the main comparison page:
> http://www.digitalmars.com/d/comparison.html
> 
> It's only showing stats for D.

Hm.  Dunno.

> Second thing. How does D allocate for a 2D (or even 3D) array. I tried to look everywhere on the D site for this, and nothing came up. I'm just curious to how it compares with the long-winded C/C++ way of using malloc to create arrays.

Well... it sorta depends.  For static/fixed-length arrays:
int[5][10] foo;
x = foo[2][3];

Its the same as this:
int[50] foo;
x = foo[(2 * 10) + 3];

At least in terms of memory layout.  The difference is in how it 
interacts with slices, typeinfo, and the meaning of the .length property.

Dynamic/variable-length arrays, on the other hand, are structures of a 
length and pointer to heap memory.  So its best to say there /are no/ 
multi-dimensional dynamic arrays -- but there /are/ arrays whose element 
type is itself an array.  A subtle difference.


> Lastly, is there a place which shows all of the D commands with a short description? What would be great too is if they were all sorted by how often each command is used.

Someone was maintaining a D keyword glossary at one time, and might 
still be, but I be darned if I can remember a link to it.  -_- 
Hopefully someone else has it bookmarked.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list