Array literals MUST be immutable.

grauzone none at example.net
Wed Feb 17 02:16:19 PST 2010


Don wrote:
> grauzone wrote:
>> IMHO array literals should be static arrays, which are value types. No 
>> issues with heap allocation or immutability requirements.
> 
> That still wouldn't solve the performance problems.

You mean even for a static array on the stack, the time to construct it 
would impose a performance problem? If that's the case, I'd say the 
optimizer should be able to tell that the array data actually is 
constant, and compile the code as if the array was immutable. I assume 
the array being a value type on the stack makes it much easier for the 
optimizer than a heap allocated array with unknown length.

Is that impossible?



More information about the Digitalmars-d mailing list