Question about arrays

Steven Schveighoffer schveiguy at yahoo.com
Mon Apr 23 04:10:28 PDT 2012


On Sat, 21 Apr 2012 18:25:44 -0400, Ali Çehreli <acehreli at yahoo.com> wrote:

> In D, arrays are what they should have been in C :). A pointer and a  
> size. Something the equivalent of the following (for the int type):
>
> struct int_Array
> {
>      int * elements;
>      size_t number_of_elements;
> }

Technically speaking, the number of elements comes first in the memory  
layout.  The fact that even seasoned D coders get it wrong (in fact, I had  
to look it up in druntime to be sure!) is a testament to how  
well-encapsulated D slices actually are.

-Steve


More information about the Digitalmars-d-learn mailing list