www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - creating void[] arrays

One problem in D that has no clear answer and continuously rears it's head  
is the void[] type being used for buffering.

The main concern is that the runtime cautiously may remove the NO_SCAN bit  
 from a void[] array.  This means false pointers.

But can we approach this from a different angle?  What if you *couldn't*  
create void arrays?  Oh, you could cast arrays to void[] but you could  
never create them as void.  In addition, you couldn't append to void[],  
concatenate void[]'s or dup them.

What problems would this cause?  Essentially, if you wanted a void[] array  
that contains pointers, you'd have to change:

auto x = new void[...];


void[] x = new void*[...];

And if you wanted one that doesn't contain pointers, you could do:

void[] x = new ubyte[...];

Any other issues?  Who does frequent void[] appending or concatenation?

Oct 14 2010