Array void init

Steven Schveighoffer schveiguy at yahoo.com
Fri Apr 26 22:29:39 PDT 2013


On Fri, 26 Apr 2013 07:58:34 -0700, Luís Marques <luismarques at gmail.com>  
wrote:

> Should this be supported?
>
>      double[8] foo = [1.0, 2.0, void, 3.0, 3.5, void, void, void];
>
> (it's not supported at the moment)

Have you considered what this does?  Consider a standard [1.0, 2.0] call:

In essence, it pushes 1.0 and 2.0 onto the stack, then calls a function to  
allocate the memory and use the given data.

What will end up happening is the data is copied from the stack to the  
heap.  It's just in your case, the data copied is garbage.  I see little  
point in supporting this.

-Steve


More information about the Digitalmars-d mailing list