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

bauss jj_1337 at live.dk
Thu Jan 6 13:33:24 UTC 2022


On Thursday, 6 January 2022 at 12:04:12 UTC, HuskyNator wrote:
> On Monday, 28 November 2016 at 14:41:44 UTC, Era Scarecrow 
> wrote:
>> On Monday, 28 November 2016 at 09:06:34 UTC, Paolo Invernizzi 
>> wrote:
>>> The point is that I was trying to avoid some cycle between 
>>> modules, detected by 2.072. This bug leads to pollution in 
>>> the use of static this only to workaround the limitation...
>>
>>  Wasn't someone working on a Associative Array static type 
>> that could be created at CTFE and run at runtime?
>
> I'm guessing there isn't.
> Sadly still running into issues because of this :(

While not the exact same, there's a small work around here that 
can help in some cases:

```d
immutable long[string] aa;
shared static this() {
     aa = [
       "foo": 5,
       "bar": 10,
       "baz": 2000
     ];
}
```


More information about the Digitalmars-d-learn mailing list