Is enum static?

John Colvin john.loughran.colvin at gmail.com
Tue Aug 20 15:23:09 PDT 2013


On Tuesday, 20 August 2013 at 19:38:34 UTC, Jonathan M Davis 
wrote:
> On Tuesday, August 20, 2013 21:33:23 John Colvin wrote:
>> I presume there's a good reason why we don't have:
>> enum a = [1,2,3,4];
>> assert assert(is(typeof(a) == int[4]));
>> 
>> this works after all:
>> enum int[4] a = [1,2,3,4];
>> assert assert(is(typeof(a) == int[4]));
>
> Array literals are always dynamic arrays, so [1, 2, 3, 4] is 
> int[] by
> definition.
>
> - Jonathan M Davis

What I was trying to say was: is there a good reason they are 
always dynamic arrays?

What would break if they were made static by default but dynamic 
on direct assignment to a dynamic array?


More information about the Digitalmars-d-learn mailing list