Indexing an associative array with a list of types

Jarrett Billingsley jarrett.billingsley at gmail.com
Sat Apr 11 19:22:40 PDT 2009


On Sat, Apr 11, 2009 at 10:11 PM, Doctor J <nobody at nowhere.com> wrote:
> grauzone Wrote:
>
>> What exactly are you trying to accomplish?
>>
>> It seems that you want to use the AA in CTFE, but it doesn't work,
>> because using AAs with classes as keys don't work in CTFE?
>
>
> Correct.  At compile time, I want to build up an associative array mapping type tuples to integers.  Then, again at compile time, I want to query it.

Ooh.  Without some serious trickery, I don't know if that's possible.
The thing is, nothing at compile time can have any kind of persistent
state - in effect, everything you use or do at compile time must be
pure.  Having some kind of compile-time registry of types built up as
they register themselves, while useful, can't really be done easily.

I've seen some persistent state kept by awful, awful means (i.e.
conditionally testing for the existence of and declaring
uniquely-named symbols in order to store some kind of info) but there
is no general mechanism for it.


More information about the Digitalmars-d-learn mailing list