Array void init

eles eles at eles.com
Fri Apr 26 08:45:26 PDT 2013


On Friday, 26 April 2013 at 14:58:35 UTC, Luís Marques 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)

which reminds me about the proposal to allow declaration of 
static arrays with

double[$] foo = [1.0, 2.0, void, 3.0, 3.5, void, void, void];

which is more convenient since one discovers a counting error 
only when compiles.

Has a decision been reached for this issue?

Currently in gdc:

double[$] foo = [1.0, 2.0];

fails with

main.d:18: Error: undefined identifier __dollar

double[1] foo = [1.0, 2.0];

fails with

main.d:18: Error: array initializer has 2 elements, but array 
length is 1

but

double[4] foo = [1.0, 2.0];

is accepted, which is a bit strange (I think the compiler should 
give at least a warning if too many elements are reserved for an 
array).


More information about the Digitalmars-d mailing list