CTFE and assoc array
Steven Schveighoffer
schveiguy at gmail.com
Tue Jan 21 21:51:35 UTC 2020
On 1/19/20 8:02 AM, Andrey wrote:
>> On Saturday, 18 January 2020 at 21:44:35 UTC, Boris Carvajal wrote:
>
> I read that thread. But:
>> Deprecation: initialization of immutable variable from static this is
>> deprecated.
>> Use shared static this instead.
That should have been noted in the original thread. shared static this
is required to initialize static immutables. Simple reason -- a static
immutable is shared between all threads, so you shouldn't be
initializing shared static data in every thread that gets created.
> And we get? No CTFE with static immutable AA?
Right, CFTE cannot access static immutable AA that are initialized at
runtime.
But you can access the enum.
e.g. (yes it's horrid):
enum sorted = Qwezzz.qazMap.keys.sort();
It would be really cool to make AA's at CTFE change into runtime AAs
when used at runtime, and be accessible as compile-time AAs otherwise.
-Steve
More information about the Digitalmars-d-learn
mailing list