On Thursday, 3 March 2016 at 10:01:47 UTC, MGW wrote:
immutable long[string] aa = [
   "foo": 5,
   "bar": 10,
   "baz": 2000
];

... Error: non-constant expression ["foo":5L, "bar":10L, "baz":2000L]

D associative arrays are a dynamic runtime feature, thus can't be initialized without runtime expressions. :(

This ended up failing too:

struct slot_t { char* key; long value; };

slot_t bogus[3] = {
        { "foo", 5L },
        { "bar", 10L },
        { "baz", 2000L }
};

import std.stdio;

void main() {
        bogus.map.writeln();
}

Reply via email to