digitalmars.D - How to initialize immutable global static array?
- dsimcha (12/12) Feb 20 2009 I want to create an immutable global static array, which should be initi...
I want to create an immutable global static array, which should be initialized in a static this() statement at program startup, or at compile time using CTFE. This can be done for dynamic arrays, since an immutable array can be assigned to once in a static constructor, and can be returned from a CTFE function, but I don't see how to do it for a static array. Basically I want something like this: immutable ubyte[SOMECONSTANT] foo; static this() { // Create array and assign it to foo, and then have foo be immutable. } Or: immutable ubyte[SOMECONSTANT] foo = someCTFEFunction(someArgument);
Feb 20 2009