Is it possible to modify DMD to allow a program like:
immutable int[int] aa = [1:15, 2: 7];
void main() {}
With the latest DMD it gives:
test.d(1): Error: non-constant expression [1:15,2:7]
Global immutable associative arrays are handy in script-like programs, I use
them now and then in Python (despite they are not immutable).
This is a workaround for script-like programs, that I sometimes use:
immutable int[int] aa;
static this() {
aa = [1:15, 2: 7];
}
void main() {}
But when possible I try to avoid using static this.
Bye,
bearophile