`static` symbol needs to be `immutable` for compile-time access?

Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 22 06:33:38 PST 2016


Thanks to all who replied.

anonymous wrote:
>> Do all values which need to
>> be readable at compile time need to be declared `immutable`?
> 
> Yes, `static immutable` or `enum`.

It would seem that in the case of arrays, the former is preferable to the 
latter, as per the para above this header:

http://ddili.org/ders/d.en/const_and_immutable.html#ix_const_and_immutable.variable,
%20immutable

But a further question, if I don't declare them as `static immutable` but 
just as `immutable`, would that mean that those arrays are necessarily 
created (meaning memory allocation) every time the function is run?

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d-learn mailing list