On 8/5/21 11:09 AM, someone wrote:
On Thursday, 5 August 2021 at 10:28:00 UTC, Steven Schveighoffer wrote:

H.S. Teoh, I know you know better than this ;) None of this is necessary, you just need `rtValue` for both runtime and CTFE (and compile time parameters)!

Now, the original question is about *associative arrays*, which are a different animal. Those, you actually have to initialize using a static constructor, and does indeed need both an enum and a static immutable, as CTFE currently does not understand runtime AAs. This is a huge issue since you do need silly things like the `if(__ctfe)` statement you wrote, and keep an enum handy for those cases which is identical to the static immutable. We really need to fix this.

When you say "We really need to fix this" you mean that *eventually* associative-arrays will be available at compile-time ?

I mean eventually AAs that are reasonably available at compile time, even though the structure is determined by the runtime, should be available at compile time. This allows them to be as usable with static immutable as regular arrays (and just about any other struct) are.

Right now, AA's implementation is completely opaque via extern(C) function prototypes implemented in the runtime, so the compiler doesn't know how to make one.

-Steve

Reply via email to