Static associative array expressions

Steven Schveighoffer schveiguy at gmail.com
Mon Sep 20 13:08:53 UTC 2021


On 9/19/21 10:10 AM, Stefan Koch wrote:
> On Sunday, 19 September 2021 at 11:39:15 UTC, pineapple wrote:
>> This could be nice. It's always been kind of annoying having to put 
>> AAs in static initializers and not being able to inspect them at 
>> compile time.
> 
> Be careful though.
> The runtime does not know if an array is in static memory or not.
> (Though it would be trivial to add a flag so it knows.)
> And Therefore when you do this:
> ```d
> static mutable_ct_createdAA = mixin(["a","b"]);
> ```
> and you mutate that array in any way.
> The runtime will crash.
> As it tries write into memory it is not supposed to write in.

How do statically initialized mutable dynamic arrays work? Should be the 
same thing.

-Steve


More information about the Digitalmars-d mailing list